Академический Документы
Профессиональный Документы
Культура Документы
Object-Oriented Modelling
1
Intended learning outcomes
• Define structural (static) models
• Implement modelling methodology
• Identify and use standard UML notation for
structural modelling
• Create simple class diagrams
• Identify opportunities for refinement
2
Key Ideas of Structural Model
• A structural (static) or conceptual model
describes the structure of the data that
supports the business processes in an
organisation.
• The structure of data used in the system is
represented through CRC cards, class
diagrams, and object diagrams.
Class name:
Description:
Responsibilities: Collaborators:
Back:
Attributes:
Relationships:
Generalization (a-kind-of):
Aggregation (has-parts):
Other Associations:
4
STRUCTURAL MODELS
5
Purpose of Structural Models
• Reduce the “semantic gap” between the real
world and the world of software
• Create a vocabulary for analysts and users
• Represent things, ideas, and concepts of
importance in the application domain
6
Classes
• Templates for creating instances or objects
• Two Kinds
– Concrete
• Used to create objects
– Abstract
• Useful abstractions
7
Attributes
• Units of information relevant to the
description of the class
• Only attributes important to the task should
be included
8
Operations
• Action that instances/objects can take
• Focus on relevant problem-specific operations
(at this point)
9
Relationships
• Generalization
– Create classes that inherit attributes and
operations of other classes
– Is-a-kind-of
• Aggregation
– Relates parts to wholes
– Has-a
• Association
– Miscellaneous relationships between classes
10
CLASS DIAGRAMS
11
Example Conceptual Class Diagram
Person
12
Class Diagram Syntax
A CLASS Class1
-attribute
+operation ()
AN ATTRIBUTE attributeName
/derivedAttributeName
AN OPERATION
operationName ()
AN ASSOCIATION
1..* 0..1
______verb phrase____
13
The Class Diagram
Use of Natural Language
Discard inappropriate candidates
◦ From the nouns in the problem statement
eliminate the
redundant
irrelevant - those unrelated to the problem
vague - ill-defined boundary, very broad in scope
attributes - things that describe an object
operations - things that manipulate objects
implementation constructs - extraneous to real world must be
eliminated from analysis model, needed during design, but not now.
14
Example: problem statement for library
automation system
15
Identify Classes
16
Identify Associations
– Associations correspond to verbs in the problem
statement
– Association = any dependency between two
classes
– From the problem statement
• Employee operates Station
– From tacit knowledge
• Library owns PC
17
Object modelling – data dictionary
• Prepare a data dictionary/ description of each
class
• Name Type Description
Station Class A terminal linked to
a central computer
operated by employees with a
barcode reader.
18
Further specify the semantics of
associations…
Include Multiplicity
How an instance of an object can be associated with
other instances
Numbers placed on association path to denote
minimum and maximum instances that can be
related through the association
minimum number .. maximum number
Numbers specify the relationship from the class at
the far end of the association to the end with the
number
19
Further specify the semantics of
associations…
Relationship Meaning
Include Multiplicity
Qualifier or Qualified Associations
◦ Usually a name identifies an object within some context;
most names are not globally unique. The context
combines with the name to uniquely identify the object.
◦ A Qualifier distinguishes objects on the many side of an
association. For example, a qualifier bankcode could be
added to distinguish the different banks in a consortium.
Each cash card needs a bank code so that transactions
can be directed to the appropriate bank.
21
Identifying Attributes and operations
• Attributes
– Properties of an individual object
– Usually possessive phrases e.g. the colour of the
car
– Identify from the problem description and domain
knowledge
• Operations
– Define ways in which objects interact
22
Identifying attributes and operations
Borrower
borrowerID
name
address
booksOnLoan
maxBooksAllowed
join()
borrow()
reserve()
return()
changeDetails()
payFine()
leave()
23
How can the class diagram be
refined?
Think Inheritance!
24
Summary
• Class and object diagrams show the
underlying structure of an object-oriented
system.
• Constructing the structural model is an
iterative process involving: textual analysis,
brainstorming objects, role playing, creating
the diagrams, and incorporating useful
patterns.
25