• No results found

Software Design

N/A
N/A
Protected

Academic year: 2020

Share "Software Design"

Copied!
46
0
0

Loading.... (view fulltext now)

Full text

(1)

Software Design

Static Modeling using the

(2)

Classes

ClassName

attributes

operations

A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.

(3)

Class Names

ClassName

attributes

operations

(4)

Class Attributes

Person

name : String address : Address birthdate : Date ssn : Id

An attribute is a named property of a

class that describes the object being modeled. In the class diagram, attributes appear in

(5)

Class Attributes (Cont’d)

Person

name : String address : Address birthdate : Date / age : Date ssn : Id

Attributes are usually listed in the form:

attributeName : Type

(6)

Class Attributes (Cont’d)

Person

+ name : String # address :

Address

# birthdate : Date / age : Date - ssn : Id

Attributes can be: + public

(7)

Class Operations

Person

name : String address :

Address

birthdate : Date ssn : Id

eat sleep

(8)

Class Operations (Cont’d)

PhoneBook

newEntry (n : Name, a : Address, p : PhoneNumber, d : Description)

getPhone ( n : Name, a : Address) : PhoneNumber

(9)

Depicting Classes

Person

name : String birthdate : Date ssn : Id

eat() sleep() work()

When drawing a class, you needn’t show attributes and operation in every diagram.

(10)

Class Responsibilities

A class may also include its responsibilities in a class diagram.

A responsibility is a contract or obligation of a class to perform a particular service.

SmokeAlarm

Responsibilities

(11)

Relationships

In UML, object interconnections (logical or physical), are modeled as relationships.

There are three kinds of relationships in UML:

• dependencies

• generalizations

(12)

Dependency Relationships

CourseSchedule

add(c : Course) remove(c :

Course)

Course

A dependency indicates a semantic relationship between two or more elements. The dependency from CourseSchedule to

Course exists because Course is used in both the add and

(13)

Generalization Relationships

Person

A generalization connects a subclass to its superclass. It denotes an

inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the

subclass

of the more general superclass.

Extended by

(14)

Generalization Relationships (Cont’d)

Student

UML permits a class to inherit from multiple superclasses,

although some programming languages (e.g., Java) do not permit multiple inheritance.

TeachingAssistant

(15)

Association Relationships

If two classes in a model need to communicate with each other, there must be link between them.

An association denotes that link.

(16)

Association Relationships (Cont’d)

We can indicate the multiplicity of an association by adding

multiplicity adornments to the line denoting the association.

The example indicates that a Student has one or more

Instructors:

Instructor Student

(17)

Association Relationships (Cont’d)

The example indicates that every Instructor has one or more

Students:

Instructor Student

(18)

Association Relationships (Cont’d)

We can also indicate the behavior of an object in an association (i.e., the role of an object) using rolenames.

Instructor Student

1..* 1..*

(19)

Association Relationships (Cont’d)

We can also name the association.

Team

Student membership

(20)

Association Relationships (Cont’d)

We can specify dual associations.

Team Student

member of

1..*

president of

1 1..*

(21)

Association Relationships (Cont’d)

We can constrain the association relationship by defining the

navigability of the association. Here, a Router object requests services from a DNS object by sending messages to (invoking the operations of) the server. The direction of the association indicates that the server has no knowledge of the Router.

(22)

Association Relationships (Cont’d)

Associations can also be objects themselves, called link classes

or an association classes.

Product

Registration

(23)

Association Relationships (Cont’d)

A class can have a self association.

LinkedListNode next

(24)

Association Relationships (Cont’d)

We can model objects that contain other objects by way of special associations called aggregations and compositions.

An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregations are

denoted by a hollow-diamond adornment on the association.

Has, Owns

Car

Engine

(25)

Association Relationships (Cont’d)

A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e., they live and die as a whole). Compositions are denoted by a filled-diamond adornment on the association.

Window

Scrollbar

Titlebar 1

1

1

(26)

Groups

• Whenever we create a subclass, we are

defining a new group of objects, that is a

subset of the superclass’ group

(27)

Overlapping/Disjoint Groups

• Overlapping/Disjoint

– Overlapping: Groups are overlapping if there

are objects that are members of both groups.

– Disjoint: Groups are disjoint if there are no

(28)

Overlapping Groups

• Overlapping/Disjoint

– Example: Say we have a superclass called

‘Movie’

– Say we have two subclasses of ‘Movie’ called

‘Comedy’ and ‘Action’

– Since it is possible for a movie to have both

action and comedy, the two groups are

(29)

Overlapping Groups

Comedy

Action

(30)

Disjoint Groups

• Overlapping/Disjoint

– Example: Say we have a superclass called

‘Book’

– Say we have two subclasses of ‘Book’ called

‘Paperback’ and ‘Hardcover’

– Since a book is either a paperback or a

(31)

Disjoint Groups

Book

(32)

Disjoint Groups

Hardcov er

Paperba ck

(33)

Complete/Incomplete Groups

• Complete/Incomplete

– Complete: The groups listed contain all

possible objects that belong to the superclass’

group

• I.e. No more disjoint subclasses can be defined

(34)

Complete Groups

• Complete/Incomplete

– Example: Consider our superclass ‘Book’ with

its subclasses ‘Hardcover’ and ‘Paperback’

– Are there any other kinds of book?

(35)

Complete Groups

Book

(36)

Complete Groups

Hardcover Paperback

(37)

Incomplete Groups

• Complete/Incomplete

– Example: Consider our superclass ‘Movie’ with

its subclasses ‘Comedy’ and ‘Action’

– Are there any other kinds of movie?

(38)

Incomplete Groups

Movie

Comedy Action

(39)

Incomplete Groups

Action

Movies

Comedy

(40)

Interfaces

An interface is a named set of

operations that specifies the behavior of objects without showing their inner structure. It can be rendered in the

model by a one- or two-compartment rectangle, with the stereotype

<<interface>> above the interface name.

(41)

Interface Services

Interfaces do not get instantiated. They have no attributes or state. Rather, they specify the services offered by a related class.

<<interface>> ControlPanel

getChoices : Choice[] makeChoice (c :

Choice)

(42)

Interface Realization Relationship

<<interface>> ControlPanel

VendingMachine

A realization relationship connects a class with an interface that supplies its

behavioral specification. It is rendered by a dashed line with a hollow triangle towards the specifier.

specifier

(43)

Interfaces

A class’ interface can also be rendered by a circle

connected to a class by a solid line.

File inputStream

FileWriter {file must not be locked}

(44)
(45)

School Department 1… * * member 1..* 1 1 1.. * has 1.. * 1.. assignedTo offeres

(46)

References

Related documents

Cost includes hotel, two meals a day, gas for transportation in the country, offering to buy beans and rice for distribution during street ministry, offerings for Pastors and two

The mainstream research, with respect to Europe, vindicates the idea of political action and the threat of violence but denies the necessity of socialism; and with respect to Latin

11.1 If the Issuer does not by the Settlement Date, for each Minimum Exercise Set exercised, deliver or cause to be delivered to the Holder, an Underlying Parcel or pay the

An individual domain instance of this property can have zero, one or more instances of this property, but an individual range instance must be referenced by exactly one instance of

This paper discusses some of the impacts attributed to climate change that are likely to hit Southern Africa as a result of increasing global greenhouse gas emissions into

15] afirma que un operador que satisfaga (|A † φi , |ψi) = (|φi , |Aψi) para todos los vectores |φi y |ψi del espacio de Hilbert es necesariamente un operador acotado.. Por

This work aimed to perform studies of molecular docking followed by molecular dynamics simulations of the enzyme UDP- N -acetylglucosamine pyrophosphorylase from the fungus M.. The

Master Planning takes the top-to-bottom, total organizational-involvement of hoshin, marries it with the measures and metrics focus of Balanced Scorecard and adds elements