object-Oriented Software Engineering Practical Software development using uml and Java Chapter 5 Modelling with Classes www.oseng.com
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes
5. 1 What is UMl? The Unified Modelling language is a standard graphical language for modelling object oriented software At the end ofthe 1980s and the beginning of 1990s, the first object- oriented development processes appeared The proliferation of methods and notations tended to cause considerable confusion Two important methodologists Rumbaugh and Booch decided to merge their approaches in 1994 They worked together at the Rational Software Corporation In 1995, another methodologist, Jacobson, joined the team -His work focused on use cases In 1997 the Object Management Group(OMG) started the process ofuml standardization www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 2 5.1 What is UML? The Unified Modelling Language is a standard graphical language for modelling object oriented software • At the end of the 1980s and the beginning of 1990s, the first objectoriented development processes appeared • The proliferation of methods and notations tended to cause considerable confusion • Two important methodologists Rumbaugh and Booch decided to merge their approaches in 1994. —They worked together at the Rational Software Corporation • In 1995, another methodologist, Jacobson, joined the team —His work focused on use cases • In 1997 the Object Management Group (OMG) started the process of UML standardization
UML diagrams Class diagrams -describe classes and their relationships Interaction diagrams show the behaviour of systems in terms of how objects interact with each other State diagrams and activity diagrams show how systems behave internally Component and deployment diagrams -show how the various components of systems are arranged logically and physically www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 3 UML diagrams • Class diagrams —describe classes and their relationships • Interaction diagrams —show the behaviour of systems in terms of how objects interact with each other • State diagrams and activity diagrams —show how systems behave internally • Component and deployment diagrams —show how the various components of systems are arranged logically and physically
UML features It has detailed semantics It has extension mechanisms It has an associated textual language -Object Constraint Language(OCL The objective of uMl is to assist in software development - It is not a methodolo www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 4
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 4 UML features • It has detailed semantics • It has extension mechanisms • It has an associated textual language —Object Constraint Language (OCL) The objective of UML is to assist in software development —It is not a methodology
What constitutes a good model? A model should use a standard notation be understandable by clients and users lead software engineers to have insights about the system provide abstraction Models are used to help create designs to permit analysis and review of those designs as the core documentation describing the system www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 5 What constitutes a good model? A model should • use a standard notation • be understandable by clients and users • lead software engineers to have insights about the system • provide abstraction Models are used: • to help create designs • to permit analysis and review of those designs. • as the core documentation describing the system
5.2 Essentials of UML Class Diagrams The main symbols shown on class diagrams are: asses represent the types of data themselves · associations represent linkages between instances of classes Attributes are simple data found in classes and their instances perations represent the functions performed by the classes and their Instances · Generalizations group classes into inheritance hierarchies www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 6
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 6 5.2 Essentials of UML Class Diagrams The main symbols shown on class diagrams are: • Classes - represent the types of data themselves • Associations - represent linkages between instances of classes • Attributes - are simple data found in classes and their instances • Operations - represent the functions performed by the classes and their instances • Generalizations - group classes into inheritance hierarchies
Classes a class is simply represented as a box with the name of the class inside The diagram may also show the attributes and operations The complete signature of an operation is operationName( parameter Name: parameter Type.) return Type Rectangle Rectangle RectangleRectangle Rectangle getArea hei ght height height: int resize idth width width int getArea getArea(: int 柔e( int, int) www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 7 Classes A class is simply represented as a box with the name of the class inside • The diagram may also show the attributes and operations • The complete signature of an operation is: operationName(parameterName: parameterType …): returnType Rectangle height: int width: int getArea(): int resize(int,int) Rectangle height width getArea resize Rectangle height width Rectangle getArea resize Rectangle
5.3 Associations and Multiplicity An association is used to show how two classes are related to each other Symbols indicating multiplicity are shown at each end of the association Employee Company Secretary Manager Company BoardofDirectors Office 0.1 Employee Perso 0,3.8 BoardofDirectors www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 8
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 8 5.3 Associations and Multiplicity An association is used to show how two classes are related to each other • Symbols indicating multiplicity are shown at each end of the association 0,3..8 * Employee * * 1..** 0..1 * Secretary Office Person Company Employee Company Manager BoardOfDirectors BoardOfDirectors
Labelling associations Each association can be labelled to make explicit the nature of the association works For Employee Company Secretary Manager supervisor Company BoardofDirectors Office 0.1 allo catedTol Employee Person 0.3.8 BoardofDirectors bo ard Member wwseng. com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 9 Labelling associations • Each association can be labelled, to make explicit the nature of the association * supervisor 1..** * w orksFor 0..1 allocatedTo * boardMember 0,3..8 * Employee Secretary Office Person Company Employee Company Manager BoardOfDirectors BoardOfDirectors
Analyzing and validating associations 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 al ways be of some company Company BoardofDirectors www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 10 Analyzing and validating associations • 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 Company BoardOfDirectors