34
Introduction - SENG 330 Object-Oriented Analysis and Design

Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Introduction - SENG 330Object-Oriented Analysis and Design

Page 2: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

SENG 330 – Fall 2006Instructor: Alex Thomo Email: [email protected] Office hours: Office Hours: TWF 12:30 - 1:30 p.m.Location: ECS 556

Objective: • How to create better object-oriented designs through

the application of a set of explainable principles and heuristics.

• How to implement these designs.

Page 3: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

SENG 330 – Fall 2006Book:

Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design, 3d Edition,

by Craig Larman

Safari at UVic?

Page 4: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Owning a hammer doesn’t make one an architect…

• Knowing an OO language is a necessary but insufficient first step to create object systems.

• Learn skills forcreation of well-designed, robust, and maintainablesoftware using OO technologies and languages

Page 5: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

UML• It’s a standard diagramming

notation…it’s not a method or procedure on how to think in objects.

• However, we need it as tool for communicating with others.– When working visually, we exploit our

brain's strength to quickly grasp symbols, units, and relationships in 2D notations.

Die

faceValue : int

getFaceValue() : introll()

DiceGame

die1 : Diedie2 : Die

play()

1

2

Page 6: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

OOD Principles and Patterns• Responsibility-driven design:

– How should responsibilities be assigned to classes of objects?– How should objects interact?– What classes should do what?

• Tried-and-true solutions to design problems have been expressed as patterns (or formulas).– E.g. Suppose there are multiple third-party tax calculators, and each tax

calculator has a different interface: TCP socket, SOAP, Java RMI, CORBA, etc.

– What objects should be responsible for these varying external tax calculator examples?

– Solution. We should create tax calculator adapters, which handle all low level details, while presenting the same external interface, e.g.getTaxes( Sale ).

Page 7: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Analysis and Design?• Analysis emphasizes an investigation of the problem and

requirements, rather than a solution.– Analysis = requirements analysis + object analysis.

• Requirement analysis is strongly related to OOA/D as a prerequisite activity. – Who will use the system? – How will it be used?– What are the expectations?

• Object analysis is about finding domain objects and concepts.

• Design is a conceptual solution that fulfills the requirements. – E.g. a description of software objects, and databases schema. – Software objects are inspired by domain objects, but not necessary the

same.

Page 8: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Plane

tailNumber

public class Plane{

private String tailNumber;

public List getFlightHistory() {…}}

domain conceptvisualization of domain concept

representation in an object-oriented programming language

Object Analysis

Page 9: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Another Example

• Dice game: – A player rolls two die. – If the total is seven, they win; Otherwise, they lose.

• Analysis– Define use cases– Define a domain model

• Design– Define interaction diagrams– Define design class diagrams

Page 10: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Uses Cases

• Requirement analysis describes domain processes: uses cases– Use cases are written stories.

• Example: Play a dice game: A player picks up and rolls the dice. If the dice face value total seven, they win; otherwise they lose.

Page 11: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Domain Model

• Object oriented analysis identifies: – domain objects, – concepts, – attributes and relationships

• Result is the domain model.

Page 12: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Player

name

DiceGame

Die

faceValueRolls

Plays

Includes

2

2

1

1

1

1

Page 13: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

OOD: Interaction Diagrams• OOD is about defining software objects,

their responsibilities and collaborations.

• A common notation for outlining the above is an interaction diagram.

Page 14: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

:DiceGame

play()

die1 : Die

fv1 := getFaceValue()

die2 : Die

roll()

roll()

fv2 := getFaceValue()

Page 15: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Or…

Page 16: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Static View: Design Class Diagrams

• It’s useful also a static view of the class definitions with design class diagrams (DCD’s).

• DCD’s are inspired by the domain model, but the classes aren’t necessarily the same.

• E.g. here is no Player class. If the requirements don’t ask to remember anything about the person playing, then there is need for such a class.

Page 17: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

2

Die

faceValue : int

getFaceValue() : introll()

DiceGame

die1 : Diedie2 : Die

play()

1

Page 18: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Three levels in applying UML• UML as sketch— Informal and incomplete diagrams

(often hand sketched on whiteboards) – created to explore difficult parts of the problem or solution

space, exploiting the power of visual languages.• UML as blueprint— Relatively detailed design

diagrams used either for – code generation (forward engineering) or for – reverse engineering to visualize and better understand

existing code• UML as programming language— Complete

executable specification of a software system in UML. – Executable code will be automatically generated, but is not

normally seen or modified by developers;

Recommended by agile

modeling.

Page 19: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Three perspectives to Apply UML• Conceptual • Specification• Implementation

• UML describes raw diagram types, such as class diagrams and sequence diagrams. It does not superimpose a modeling perspective on these. – For example, the same UML class diagram notation can be

used to draw pictures of concepts in the real world or software classes in Java.

Page 20: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Iterative Development and the Unified Process

Page 21: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

(Rational) Unified Process• A software development process describes an

approach to Software– Building– Deploying– Maintaining

• There are many activities comprising the above. • Recommended to follow: The Unified Process,

– A procedure for doing the many possible activities from requirements to implementation, and maintenance.

Page 22: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Key UP Idea: Iterative Development

• An iterative development is organized into a series of short, fixed-length mini-projects called iterations.

• The outcome of each iteration is a tested, integrated, and executable system.

• Each iteration includes its own requirement analysis, design, implementation, and testing activities.

Page 23: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

• Each iteration involves choosing a small set of requirements, and quickly designing, implementing, and testing.

• Feedback is from users, developers, and tests (such as load and usability tests). E.g.

Feedback from users or stakeholders: You don’t differentiate between products when calculating tax!Feedback from programmers: To print in special purpose paper is a daunting task! Is it worthy?Feedback from tests: To ask GoodAsGoldTaxPro calculator is very slow. (load test)

Page 24: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Why Iterations?Some facts:• Changes in requirements: 35% - 50%• Software development is a domain of high change and

instability. • Software is not a domain of predictable or mass

manufacturing. • Change is the constant in software projects.• Any analysis, modeling, development, or management

practice based on the assumption that things are long-term stable (i.e., the waterfall) is fundamentally flawed.

Page 25: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

How to do Iterative and Evolutionary Analysis and Design?

1. Before iteration-1, hold the first timeboxed requirements workshop (2 days). Business and development people are present.

– On the morning of day one, identify the names of the use cases. The analysis will not be perfect.

– Ask the chief architect and business people to pick 10% from this high-level list (such as 10% of the 30 use case names), which have a blending of three qualities:

1) architecturally significant2) high business value (features business really cares about)3) high risk (such as "be able to handle 500 concurrent transactions").

Perhaps three use cases are identified: UC2, UC11, UC14.– For the remaining 1.5 days, do intensive detailed analysis for these three

use cases (write them up).

Page 26: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

How to do Iterative and Evolutionary Analysis and Design?

2. Before iteration-1, hold an iteration planning meeting a subset from UC2, UC11, and UC14 are chosen to design, build, and test within a specified time (for example, four-week timeboxed iteration).

3. Do iteration-1 over four weeks.– On the first two days, developers and others do modeling and design work in

pairs, sketching UML diagrams at many whiteboards in a common war room…– Then the developers take off their "modeling hats" and put on their "programming

hats."– Much testing occurs. – One week before the end, ask the team if the original iteration goals can be met; if

not, de-scope the iteration, putting secondary goals back on the "to do" list.– On Tuesday of the last week there's a code freeze; all code must be checked in,

integrated, and tested to create the iteration baseline.– On Wednesday morning, demo the partial system to external stakeholders, to

show early visible progress. Feedback is requested.

Page 27: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

UP Phases• A UP project organizes the iterations across four major phases:• Inception

– approximate vision, – business case, – scope, – vague estimates.

• Elaboration– refined vision– iterative implementation– resolution of high risks

• Construction– iterative implementation of lower risk elements

• Transition– beta tests– deployment

Page 28: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned
Page 29: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

UP Disciplines

• UP describes work activities, such as writing a use case, within disciplines (work-codes).

• There are several disciplines:– Business modeling – e.g. domain modeling– Requirements – e.g. writing use cases– Design – all aspects of design, e.g. objects, databases,

networking etc. – …

Page 30: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Disciplines and phases

Page 31: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Case Study: The NextGen POS System

Page 32: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

A POS System• A computerized NextGen point-of-sale (POS) system is to:

– record sales, and – handle payments.

• It includes H/S components such as:– Computer– Bar code scanner– Software

• It interfaces to various service applications, such as:– Third party tax calculators– Inventory control

• It must support multiple and varied client-side terminals and interfaces, such as:– A thin Web browser terminal– A regular PC with Java Swing graphical UI– Touch screen input– Wireless PDA’s

• Furthermore, it should support different clients with different business rules.

Page 33: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Business rules…

– “When you sell a widget, total the monthly sale figures, and decrease the widget inventory.”

– “Only a manager can discount blue widgets by 10%.”

Page 34: Introduction - SENG 330webhome.cs.uvic.ca/~thomo/courses/seng330Fall2006/... · OOD Principles and Patterns • Responsibility-driven design: – How should responsibilities be assigned

Interface

Sale Payment

Log Pers is tenceFacade

applicationlog ic anddomain objec tlayer

technicals ervices layer

minor focus

explore how to connect toother layers

primary focus ofcase s tudy

explore how todes ign objects

secondaryfocus

explore howto des ignobjects

Architectural Layers