Analysis Modeling

23
Analysis Modeling Static Modeling

description

Analysis Modeling. Static Modeling. Requirements analysis. Results in static and dynamic models Scenario models: use cases (static), swimlane diagrams (dynamic) Class diagrams (static) Flow oriented diagrams (dynamic) - PowerPoint PPT Presentation

Transcript of Analysis Modeling

Page 1: Analysis Modeling

Analysis Modeling

Static Modeling

Page 2: Analysis Modeling

Requirements analysis

• Results in static and dynamic models– Scenario models: use cases (static), swimlane

diagrams (dynamic)– Class diagrams (static)– Flow oriented diagrams (dynamic)– Behavioral models: sequence diagrams (dynamic),

state diagrams (dynamic)• These models bridge the gap between

requirements and implementation (code)

Page 3: Analysis Modeling

Classes through Class diagrams

• We’ve done use cases, time to move on to candidate classes, all of which should:– Retain information– Need services– Have multiple attributes– Have common attributes and operations– Be essential requirements (in the problem space)

Page 4: Analysis Modeling

Selecting classes: example

• Run this slide to see animation

needed services

multiple attributes

common attributes

common operations

essential requirements

retained informationATMUser

Yes

Yes

Yes

Yes

Yes

Yes

PinNum

Yes

No

No

Yes

Maybe

Yes

Page 5: Analysis Modeling

Class diagrams

• A box with at least three compartments:

– Class name– Attributes– Operations– Responsibilities – User-defined compartment

• Each class associated with other classes

Student

-major: String-gpa: Real-standing: String

+add(section: Section)+drop(section: Section)-- The set of students known to the registration system

-- An exception occurs if gpa falls below 2.0

Page 6: Analysis Modeling

Attribute syntax

• visibility: public “+”, protected “#”, or private “-”• name: capitalize first letter of each word that

makes up the name, except for the first• multiplicity: number, range, or sequence of

number or ranges.• type: built-in type or any user-defined class• initial-value: any constant and user-defined object• property-string: e.g, changeable, addOnly, frozen

[visibility] name [multiplicity] [:type] [=initial-value][{property-string}]

Page 7: Analysis Modeling

Operation syntax

• visibility: “+”, “#”, “-”• name: verb or verb phase, capitalize first letter of

every word, except first• parameter-list: coma separated list of parameters• return-type: primitive type or user-defined type• property-string: isQuery, sequential, guarded,

concurrent

[visibility] name [(parameter-list)] [:return-type] [{property-string}]

Page 8: Analysis Modeling

Example associationStudent

-major: String-GPA: Real-standing: String

+add(Section)+drop(Section)

Section

-name: String-capacity: Integer

+add(Student)+drop(Student)+checkPrereq(List<Student>)

Here, a Student is associated with a Section; one or both need the other in order to function

Page 9: Analysis Modeling

Associations

• An association is a structural relationship that specifies that objects of class may be connected to objects of another class

• Associations typically represent “long-lived” relationships – In a library system a Person always has a

name (association), but may infrequently have a book (dependency)

Page 10: Analysis Modeling

Association syntax

• Connect two classes• Have labels and roles• Have multiplicities• Are directional (related to “has a”

relationship) – the navigation– Think about which class needs to know about

the other; which class is an attribute of the other? Why/when do I care?

Page 11: Analysis Modeling

Exercise: How many instructors can a class section have?

Student

Class Section

Course

Semester

Instructor

Department

<wor

ks fo

r1..*

1

1..*

1..*11

1..*

0..8

0..*

0..61..3

Page 12: Analysis Modeling

How many instructors can a class section have? Answer: 1 to 3

Student

Class Section

Course

Semester

Instructor

Department

<wor

ks fo

r1..*

1

1..*

1..*11

1..*

0..8

0..*

0..61..3

Page 13: Analysis Modeling

Attribute vs Association

• name is the role on the association (attribute)• We generally don’t model built-in classes like String

(they are just types for attributes)

joe: Student-name: String = “Joe Jones”

joe: Student Joe Jones : String

Is basically the same as ...

name1

Page 14: Analysis Modeling

Types of associations

Relation

AssociationGeneralization Dependency

Aggregation

Binary Association N-ary Association

Page 15: Analysis Modeling

Generalization

• A triangle on the side of the general class• Same as inheritance hierarchy in Java• Opportunity for reuse

StudentPerson Graduate Student

Page 16: Analysis Modeling

Dependency

• One class uses another, but it’s a weaker form of association– Not necessarily long-lived; the depend-or can exist without a depend-ee in the system

• Dashed line

Page 17: Analysis Modeling

Aggregation

• Means “part of”• Symbolized by a white diamond

1 1

*

4..*

1

1

1 1

1..3 1

0..9 1

Pizza Order

Slice

Crust

Sauce Serving

Cheese Serving

Topping Serving

Page 18: Analysis Modeling

Composition

• Like aggregation, but the component cannot survive on its own

• Symbolized by a black diamond

BuildingRoom

Page 19: Analysis Modeling

Exercise• Take a look at

http://www.cs.gmu.edu/~kdobolyi/cs321/BookstoreExample4.jpg

• Does John McCain (who has 7 houses) have a problem using this system?

• If Barack Obama decides to create a Federal sales tax, how would we change the system?

• Why is there a display method in Item, Book, MusicCD and Software?

• An ItemOrder is part of how many Orders?• Can you explain how a search works using this diagram?

Page 20: Analysis Modeling

Answer• Take a look at http://www.cs.gmu.edu/~kdobolyi/cs321/BookstoreExample4. jpg• Does John McCain (who has 7 houses) have a problem using this

system?– Yes; only 2 addresses associated with a customer

• If Barack Obama decides to create a Federal sales tax, how would we change the system?– add federalTax attribute to Order class

• Why is there a display method in Item, Book, MusicCD and Software?– each subclass has its own implementation, even though one was inherited from

the parent• An ItemOrder is part of how many Orders?

– 1• Can you explain how a search works using this diagram?

– No; this is a static diagram, and does not show “flow” or actions

Page 21: Analysis Modeling

Quiz review• What two main components make up a class in a class diagram?• How do you represent an attribute? What are all the options/parts?• How do you represent a method? What are all the options/parts?• What is an association? Draw it.• What is a dependency? Draw it.• What is a generalization? Draw it.• What is an aggregation/composition? Draw it.• When do you include an attribute, as opposed to modeling it with an

association?• What do the arrows mean on associations?• What do the multiplicities mean on associations?

Page 22: Analysis Modeling

In-class exercise

• Let’s make a class diagram for an ATM– Include a dependency– Include a generalization– Include a composition– Include all multiplicities– label all attributes

• Complete the exercises at http://www.cs.gmu.edu/~kdobolyi/cs321/hwk03.html• Due next class

Page 23: Analysis Modeling

Team Project

• Examine the Quiz Game description/use cases• In your teams, come up classes;

– At least one dependency, aggregation, and generalization

– All associations must have navigations and multiplicities

– All attributes and operations must have types and visibilities

• Turn in this assignment through XP-Dev