BIT201 Obj ect Modeling using UML
Developing the Conceptual Model
1
Chong Ven Yu
Readings
z Larman
zChapter 9: Building a Conceptual Model
zChapter 10: Adding Attributes
2
zChapter 11: Adding Associations
z Reading 2: Novak and Gowin
zConcept Mapping for Meaningful Learning
Modeling Systems
z Modelsare meant to describe and abstract certain aspects of a
real-world system, which may be very complex.
z Object-Oriented Analysis and Design areprocessesin which
3
models are created
.
Object-Oriented A & D
z
Object-Oriented Analysis:
z
focus on finding and describing the objects and concepts
in the problem domain
4 z
Object-Oriented Design:
z
emphasis on defining logical software objects that will be
implemented
z
Object-Oriented Programming:
z
the design components are implemented using an
Object-Oriented Programming Language
Object-Oriented Analysis
z Involves four main activities z These activities are done iteratively:
Create System Definition
5
Define System Requirements
Build Object Model
Finalize Analysis Documentation
Object-Oriented Analysis
z
Artifacts that will be generated in Object-Oriented
Analysis:
z
Conceptual Model
6
z
Use Case Diagram
z
High Level Use Case
z
Expanded Use Case
z
System Sequence Diagram
Conceptual Models
z A conceptual model shows
zConcepts
zAssociation between concepts
zAttributes of concepts
7 z Clarifies terminology or vocabulary of the domain
z Communicates to developers what the important terms are and how they are related
HVR Conceptual Model
Media type numberOfDays rentalFee overdueFeePerDay
1 1
VideoStore
1 1
has-catalog-of
1 1
stocks Member
name b Id 1
1
records
* *
8 Video Item
barcode dateAcquired status Video Specification
title producer dateReleased numberOfCopies
falls-under
1 1
describes
Rental rentalDate dueDate returnDate rentalFee overdueFee 1
1 taken-on
memberId phone address depositPaid membershipExpiryDate 1
1
performs
1..* * *
1..* *
Concepts
z
A concept is an
idea
,
thing
or
object
.
z
A concept consists of:
z
Symbol
– words or images representing a concept
z
Intension
– definition of a concept
9 z
Extension
– set of examples to which the concept
applies
z
E.g. consider an event of a sale transaction.
z
Name – Sale
z
Intension – ‘represents the event of a purchase
transaction and has a date and time’
z
Extension – all examples or instances of sales
Strategies to Identify
Concepts
z Better to overspecify a conceptual model
z Do not exclude a concept because the requirements do not indicate an obvious role or because it has no attributes.
1 0 z Quite valid to have attributeless concepts
z Identify the nounand noun phrasesin textual descriptions of a problem domain especially the expanded use cases
How to Make a
Conceptual Model
z List the candidate concepts using the Concept Category List and noun phrase identification
z Draw them in a conceptual model – as a concept map. z Add the associations to record relationships
z Add the attributes required to fulfil the information requirements. z Use the existing names found in the requirements specification z Exclude irrelevant features
z Do not add things that are not there
The Unified Modeling
Language
z “… is a language for specifying, visualizing and constructing the artifacts of software system...”
z A notational systemaimed at modeling systems using OO concepts.
z Initially developed by Grady Booch and Jim Rumbaugh (1994) to combine the Booch and OMT methods
z Later joined by Ivar Jacobson, creator of OOSE (Object-Oriented Software Engineering) method.
UML Definitions
Terms UML Definition
Class Description of a set of objects that share the same attributes, operations, methods, relationships and semantics.
ImplementationAn implemented software class e g
1 3 Implementation An implemented software class e.g.
Class a Java class.
Operation A service that can be requested from an object to effect ‘behaviour’.
UML Definitions
Terms UML Definition
Method Implementation of an operation’s algorithm or procedure
Type Similar to class – describes a set of like
objects with attributes and operations but may not include any methods
1 4
may not include any methods
Interface A set of externally visible operations.
Association Structural relationships between objects of different types
Associations
z An association is a relationship between concepts indicating some meaningful and interesting connection.
z Associations imply knowledge of a relationship which needs to be preserved for some duration
z Association Guidelines
1 5 z Association Guidelines
zFocus on those associations for which knowledge of the relationship needs to be preserved for some time
z Naming Associations
zName an association based on
TypeName-VerbPhrase-TypeName
Multiplicities
z Multiplicity defines how many instances of type Acan be associated with one instance of type B, at a particular moment in time.
Mem ber nam e mem berId phone
dd
1 6 z Example: Onevideo item can be associated with many rentals, but each
rental is for onevideo item and onecustomer.
1
performs
1..* 1
address depositPaid mem bershipE xpiryDate Rental
rentalDate dueDate returnDate rentalFee overdueFee *
tak en -on
1 1 Video Item barc ode date Ac quired stat us
Attributes
z An attribute is a logical data value of an object
z Attributes in a conceptual model should be simple attributes or pure data values. E.g.
tt ib t t B l D t N b St i
1 7 zattribute types: Boolean, Date, Number, String….
ztypical attributes: Name, Address, Colour, Size, Status
z Attributes should not be foreign keys
Summary
z A conceptual model is not strictly correct or wrong.
z It provides a useful description of the concepts and their important relationships.
z The model is updated in subsequent development cycles.
BIT201 Obj ect Modeling using UML
Developing the Conceptual
Model (2)
1 9
CONCEPTUAL MODEL
z Classes
zA class describes a set of objects with an equivalent role or
roles in a system.
2 0 zEvery object belongs to a class.
CONCEPTUAL MODEL
What kind of things are classes ?
z Tangibleor‘real-world’things: book,copy, course
z Roles: library member, student
2 1 z Events: arrival,leaving, request
z Interactions: meeting
CONCEPTUAL MODEL
z What makes a class model good?
zBuilda system as quickly and cheaply as possible, satisfying current requirements
zevery behaviour required of the system must be provided for by
2 2
y q y p y
the objects
zBuilda system which is easy to maintain and adapt to future requirements
zsystem should composed of encapsulated modules, with low coupling and high cohesion
CONCEPTUAL MODEL
How to build a good class model ? z Noun Identification.
z Identify candidate classes by selecting nouns and noun phrases from the requirements specification.
z Discard inappropriatecandidates.
R d d t h th l i i th
zRedundant when the same class is given more than one name. E.g. ‘loan’ and ‘short term loan’are different but probably only in the value of the attributes.
zVague, cannot tell unambiguously what is meant by a noun.
zAn eventor an operation, where the noun refers to something which is done to, by or in the system. Determine if an instance of the event or operation has state, behaviour and identity. Ifnot, discard it.
CONCEPTUAL MODEL
Associations
z associations correspond to verbs
z express relationshipsbetween classes
z links are instances of associations
z class Aand class B are associated if :
zan object of class Asends a message to an object of class B
zan object of class Acreates an object of class B
zan object of class Ahas an attribute whose values are objects of class B, or collections of objects of class B
CONCEPTUAL MODEL
Multiplicities
z Multiplicity defines how many instancesof class A can be associated with one instance of class B, at a particular moment in time
2 5
time.
Store
1
1
stocks
*
*
Item
GEN-SPEC
Generalization
z Every memberOfStaff is a LibraryMember
z memberOfStaff is more specializedthan
LibraryMember
2 6
LibraryMember - or - LibraryMember is a
generalization of MemberOfStaff
zsome operations may only be specific to
memberOfStaff
MemberOfStaff
GEN-SPEC
z The conceptual model can be extended using generalization. z Generalization is the activity of
zidentifying commonality among concepts
zdefining supertype and subtype relationships
2 7
Credit Pay ment Cheque Payment Cash Payment
Payment suupertype - more general
subtype - mor e specialized
SUBTYPE/SUPERTYPE
z A supertype definition is more general or encompassing than a subtype definition.
z All the instances of a subtype are instances of their supertype set.
E l
M ember name m emberId phone address
2 8
z Example:
zA Student Member is a Member
Student Member collegeName studentId discountRate deposit Paid m embershipEx piryDat e
SUBTYPE/SUPERTYPE
z Create a subtype of a supertype when: zThe subtype has additional attributes of interest
zThe subtype has additional associations of interest
zThe subtype concept is operated upon, handled, reacted to or manipulated differently than the supertype or other subtypes, in
2 9
p y p yp yp ,
ways that are of interest.
zThe subtype represents an animate thing that behaves
differently from the supertype or other subtypes
z These should all be considered in the context of the problem
domain.
Abstract Types
If every member of a type T is also a member of a subtype, then type T is called an abstract type.
3 0 Credit Payment Cheque Payment
Cash Payment
Aggregation and
Composition
Aggregation is a kind of association for modeling
whole-part relationships
3 1
Ha nd Fin ger
1
1 0..7
AGGREGATION
z Aggregationis a way of recording that an object is part of an object of another class
z An object can simultaneously be part of several other objects e.g.
3 2
j y p j g
a single Modulecould be part of several different
HonoursCourses.
HonoursCourse 1..* ** Module
COMPOSITION
z Compositionis a special kind of aggregation.
z In acompositionassociation, the whole strongly owns its parts. z If the wholeobject is copied or deleted, its parts are copied or
deleted with it.
3 3 z The multiplicity at the whole end must be 1or 0..1i.e. a part cannot
be part of more than one whole by composition.
z Composition is shown like an aggregation, except that the diamond is filledin.
z An object can simultaneously be part of several other objects e.g. a single Module could be part of several different HonoursCourses.
Board *
1
Square * 1
GEN-SPEC
Inheritance
z Problem: a Lecturerclass has been implemented. Add a new class called DirectorOfStudies, a kind of lecturer who apart from performing the same duties as a lecturer, is responsible for overseeing the progress of certain students.
3 4
z Solution: specify DirectorOfStudiesas a subclass of Lecturerand include in the class the extra attributes and operations of DirectorOfStudies.
zPossible for DirectorOfStudiesto implement different behaviour, on receipt of some message, from what lecturer implements
zAs well as inheriting the methods of Lecturer, DirectorOfStudies can include a new method implementing the same operation for which Lectureralready had a method
GEN-SPEC
z Inheritance
zDirectorOfStudies inherits from Lecturer
zDirectorOfStudies is a subclass (derived class) of Lecturer
zDirectorOfStudies is a specialization of Lecturer
Le ct ure r
name
submit Marks() p
zDirectorOfStudies is more specialized than Lecturer
zLecturer is a superclass (base class) of DirecorOfStudies
zLecturer is a generalization of DirectorOfStudies
Dire ct orOfSt udies
overseeSt udent s()
Association Classes
z An association between two classes can be treated as a classwith attributes and operations.
z The name of the association class and the name of the association should be the same.
M odule **
An Association Class avoiding an Association Class
1..* 1 Student 1..* * Module
Mark * 1
is taking 1..* * 1
* 1..* 1
S tudent 1. .*
is tak ing 1. .*