SEG 4110 Advanced Software Design and Reengineering TOPIC

  • Slides: 51
Download presentation
SEG 4110 – Advanced Software Design and Reengineering TOPIC A Review of UML

SEG 4110 – Advanced Software Design and Reengineering TOPIC A Review of UML

What is UML? The Unified Modelling Language is a standard graphical language for modelling

What is UML? The Unified Modelling Language is a standard graphical language for modelling object oriented software • Developed when Booch, Rumbagh and Jacobson merged their approaches. • In 1997 the Object Management Group (OMG) started the process of UML standardization SEG 4110 - Topic A- Review of UML 2

Reminder about Naming classes • Use capital letters —E. g. Bank. Account not bank.

Reminder about Naming classes • Use capital letters —E. g. Bank. Account not bank. Account • Use singular nouns • Use the right level of generality —E. g. Municipality, not City • Make sure the name has only one meaning —E. g. ‘bus’ has several meanings SEG 4110 - Topic A- Review of UML 3

Umple A technology for programming in UML • Model-Oriented Programming Adds associations and attributes

Umple A technology for programming in UML • Model-Oriented Programming Adds associations and attributes to programming languages • Java • PHP • Ruby Stand alone code-generator is online at • http: //cruise. site. uottawa. ca/umpleonline/index. php SEG 4110 - Topic C - Advanced UML and Umple 4

Declaration of classes and attributes in Umple class Student { student. Number; // defaults

Declaration of classes and attributes in Umple class Student { student. Number; // defaults to String grade; Integer entry. Average; // implemented as int } Open in Umple. Online SEG 4110 - Topic C - Advanced UML and Umple 5

Associations class Student { id; name; } class Course { description; code; } class

Associations class Student { id; name; } class Course { description; code; } class Course. Section { section. Letter; 1. . * -- 1 Course; } association { * Course. Section; * Student registrant; } Open the above in Umple. Online SEG 4110 - Topic C - Advanced UML and Umple 6

Selected patterns class University { singleton; String name; } Open the above in Umple.

Selected patterns class University { singleton; String name; } Open the above in Umple. Online SEG 4110 - Topic C - Advanced UML and Umple 7

Reminder about Labelling associations • Each association can be labelled, to make explicit the

Reminder about Labelling associations • Each association can be labelled, to make explicit the nature of the association SEG 4110 - Topic A- Review of UML 8

Analyzing and validating associations 1 • Many-to-one —A company has many employees, —An employee

Analyzing and validating associations 1 • Many-to-one —A company has many employees, —An employee can only work for one company. - This company will not store data about the moonlighting activities of employees! —A company can have zero employees - E. g. a ‘shell’ company —It is not possible to be an employee unless you work for a company Employee * works. For SEG 4110 - Topic A- Review of UML 1 Company 9

Analyzing and validating associations 2 • Many-to-many —A secretary can work for many managers

Analyzing and validating associations 2 • Many-to-many —A secretary can work for many managers —A manager can have many secretaries —Secretaries can work in pools —Managers can have a group of secretaries —Some managers might have zero secretaries. —Is it possible for a secretary to have, perhaps temporarily, zero managers? Assistant * 1. . ** supervisor SEG 4110 - Topic A- Review of UML Manager 10

Analyzing and validating associations 3 • One-to-one —For each company, there is exactly one

Analyzing and validating associations 3 • One-to-one —For each company, there is exactly one board of directors —A board is the board of only one company —A company must always have a board —A board must always be of some company 1 1 SEG 4110 - Topic A- Review of UML 11

Analyzing and validating associations Avoid unnecessary one-to-one associations Avoid this do this SEG 4110

Analyzing and validating associations Avoid unnecessary one-to-one associations Avoid this do this SEG 4110 - Topic A- Review of UML 12

Association classes • Sometimes, an attribute that concerns two associated classes cannot be placed

Association classes • Sometimes, an attribute that concerns two associated classes cannot be placed in either of the classes • The following are equivalent SEG 4110 - Topic A- Review of UML 13

Reflexive associations • It is possible for an association to connect a class to

Reflexive associations • It is possible for an association to connect a class to itself class Course { * prerequisite -- * Course successor; * self multually. Exclusive; } Open in Umple (the symmetric reflexive association doesn’t show graphically yet) SEG 4110 - Topic A- Review of UML 14

Directionality in associations • Associations are by default bi-directional • It is possible to

Directionality in associations • Associations are by default bi-directional • It is possible to limit the direction of an association by adding an arrow at one end • Open in Umple SEG 4110 - Topic A- Review of UML 15

Object Diagrams • A link is an instance of an association —In the same

Object Diagrams • A link is an instance of an association —In the same way that we say an object is an instance of a class SEG 4110 - Topic A- Review of UML 16

Inheritance and the Isa Rule Inheritance • The implicit possession by all subclasses of

Inheritance and the Isa Rule Inheritance • The implicit possession by all subclasses of features defined in its superclasses Always check generalizations to ensure they obey the isa rule • “A checking account is an account” • “A village is a municipality” Should ‘Province’ be a subclass of ‘Country’? • No, it violates the isa rule —“A province is a country” is invalid! SEG 4110 - Topic A- Review of UML 17

Inheritance, Polymorphism and Variables SEG 4110 - Topic A- Review of UML 18

Inheritance, Polymorphism and Variables SEG 4110 - Topic A- Review of UML 18

Avoiding unnecessary generalizations Inappropriate hierarchy of classes, which should be instances Improved class diagram,

Avoiding unnecessary generalizations Inappropriate hierarchy of classes, which should be instances Improved class diagram, with its corresponding instance diagram : Recording. Category video audio subcategory subcategory : Recording. Category music video jazz blues classical rock : Recording 9 th Symphony Beethoven Let it be The Beatles SEG 4110 - Topic A- Review of UML 19

Avoiding having instances change class • An instance should never need to change class

Avoiding having instances change class • An instance should never need to change class SEG 4110 - Topic A- Review of UML 20

Composition • A composition is a strong kind of aggregation —if the aggregate is

Composition • A composition is a strong kind of aggregation —if the aggregate is destroyed, then the parts are destroyed as well SEG 4110 - Topic A- Review of UML 21

Interfaces An interface describes a portion of the visible behaviour of a set of

Interfaces An interface describes a portion of the visible behaviour of a set of objects. • An interface is similar to a class, except it lacks instance variables and implemented methods SEG 4110 - Topic A- Review of UML 22

OCL – More to come in a later lecture SEG 4110 - Topic A-

OCL – More to come in a later lecture SEG 4110 - Topic A- Review of UML 23

Use Case Diagrams SEG 4110 - Topic A- Review of UML 24

Use Case Diagrams SEG 4110 - Topic A- Review of UML 24

Example of generalization, extension and inclusion SEG 4110 - Topic A- Review of UML

Example of generalization, extension and inclusion SEG 4110 - Topic A- Review of UML 25

Example Description of a Use Case SEG 4110 - Topic A- Review of UML

Example Description of a Use Case SEG 4110 - Topic A- Review of UML 26

Sequence diagrams – an example SEG 4110 - Topic A- Review of UML 27

Sequence diagrams – an example SEG 4110 - Topic A- Review of UML 27

Sequence Diagrams – an example with replicated messages • An iteration over objects is

Sequence Diagrams – an example with replicated messages • An iteration over objects is indicated by an asterisk preceding the message name SEG 4110 - Topic A- Review of UML 28

Sequence Diagrams – an example with object deletion • If an object’s life ends,

Sequence Diagrams – an example with object deletion • If an object’s life ends, this is shown with an X at the end of the lifeline SEG 4110 - Topic A- Review of UML 29

State Diagrams – an Example of Transitions with Time-outs and Conditions SEG 4110 -

State Diagrams – an Example of Transitions with Time-outs and Conditions SEG 4110 - Topic A- Review of UML 30

State Diagrams – Example with Conditional Transitions - Course. Section class Planned open. Registration

State Diagrams – Example with Conditional Transitions - Course. Section class Planned open. Registration close. Registration Cancelled Open. Not. Enough. Students cancel class. Size >= minimum close. Registration Closed Open. Enough. Students class. Size >= maximum request. To. Register (a. Student) /create. Registration SEG 4110 - Topic A- Review of UML 31

State Diagram – An Example with Substates Course. Section Class Again Open the previous

State Diagram – An Example with Substates Course. Section Class Again Open the previous page and this one in Umple SEG 4110 - Topic A- Review of UML 32

Activity Diagrams – An Example – Course Registration SEG 4110 - Topic A- Review

Activity Diagrams – An Example – Course Registration SEG 4110 - Topic A- Review of UML 33

Package Diagrams SEG 4110 - Topic A- Review of UML 34

Package Diagrams SEG 4110 - Topic A- Review of UML 34

Example of Multi-Layer Systems SEG 4110 - Topic A- Review of UML 35

Example of Multi-Layer Systems SEG 4110 - Topic A- Review of UML 35

Component Diagrams SEG 4110 - Topic A- Review of UML 36

Component Diagrams SEG 4110 - Topic A- Review of UML 36

An Example of a Distributed System SEG 4110 - Topic A- Review of UML

An Example of a Distributed System SEG 4110 - Topic A- Review of UML 37

Example of a Broker System SEG 4110 - Topic A- Review of UML 38

Example of a Broker System SEG 4110 - Topic A- Review of UML 38

Example of a Pipe-and-Filter System Sound Processing SEG 4110 - Topic A- Review of

Example of a Pipe-and-Filter System Sound Processing SEG 4110 - Topic A- Review of UML 39

Example of the MVC Architecture for a User Interface SEG 4110 - Topic A-

Example of the MVC Architecture for a User Interface SEG 4110 - Topic A- Review of UML 40

Example of the Service-Oriented Architecture SEG 4110 - Topic A- Review of UML 41

Example of the Service-Oriented Architecture SEG 4110 - Topic A- Review of UML 41

Abstraction-Occurrence SEG 4110 - Topic A- Review of UML 42

Abstraction-Occurrence SEG 4110 - Topic A- Review of UML 42

Abstraction-Occurrence Square variant SEG 4110 - Topic A- Review of UML 43

Abstraction-Occurrence Square variant SEG 4110 - Topic A- Review of UML 43

General Hierarchy SEG 4110 - Topic A- Review of UML 44

General Hierarchy SEG 4110 - Topic A- Review of UML 44

Player-Role SEG 4110 - Topic A- Review of UML 45

Player-Role SEG 4110 - Topic A- Review of UML 45

Singleton SEG 4110 - Topic A- Review of UML 46

Singleton SEG 4110 - Topic A- Review of UML 46

Observer SEG 4110 - Topic A- Review of UML 47

Observer SEG 4110 - Topic A- Review of UML 47

Delegation SEG 4110 - Topic A- Review of UML 48

Delegation SEG 4110 - Topic A- Review of UML 48

Façade SEG 4110 - Topic A- Review of UML 49

Façade SEG 4110 - Topic A- Review of UML 49

Proxy SEG 4110 - Topic A- Review of UML 50

Proxy SEG 4110 - Topic A- Review of UML 50

Deployment Diagrams SEG 4110 - Topic A- Review of UML 51

Deployment Diagrams SEG 4110 - Topic A- Review of UML 51