Download Modelling with Classes - Banking - Lecture Slides and more Slides Banking and Finance in PDF only on Docsity!
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 of the 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 of UML standardization
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.
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
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
Analyzing and validating associations
- 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 (^) * worksFor^1 Company
Analyzing and validating associations
- Many-to-many —An assistant can work for many managers —A manager can have many assistants —Assistants can work in pools —Managers can have a group of assistants —Some managers might have zero assistants. —Is it possible for an assistant to have, perhaps temporarily, zero managers? * supervisor
Assistant 1..*^ ***** Manager
Open in Umple
Analyzing and validating associations
Avoid unnecessary one-to-one associations
Avoid this do this
A more complex example
- A booking is always for exactly one passenger —no booking with zero passengers —a booking could never involve more than one passenger.
- A Passenger can have any number of Bookings —a passenger could have no bookings at all —a passenger could have more than one booking
- The frame around this diagram is an optional feature that any UML 2.0 may possess.
Reflexive associations
- It is possible for an association to connect a class to itself
Open in Umple
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
Avoiding unnecessary generalizations
Inappropriate hierarchy of classes, which should be instances
Avoiding unnecessary generalizations (cont)
Improved class diagram, with its corresponding instance diagram
Open in Umple