Beruflich Dokumente
Kultur Dokumente
Structural Modeling
Most slides are adopted from the textbook “Systems Analysis and
Design with the Unified Modeling Language, Version 2.0” Alan
Dennis, Barbara Wixom, and David Tegarden © 2005
Analysis and Design Information System – MTI Fasilkom 2007
Key Ideas
Use-case models provide an external functional view
of the system (what the system does)
A structural or conceptual models describe the
structure of the data that supports the business
processes in an organization.
The structure of data used in the system is represented
through CRC cards, class diagrams, and object
diagrams.
Analysis and Design Information System – MTI Fasilkom 2007
Purpose of Structural Models
A structural model is a formal way of representing
the objects (things, ideas, and concepts) that are used
and created by a business system
Reduce the “semantic gap” between the real world
and the world of software
The real world tends to be messy, whereas the world of
software must be neat and logical
Create a vocabulary for analysts and users to
communicate effectively
Structural model also allow the representation of
the relationships between the objects
Analysis and Design Information System – MTI Fasilkom 2007
Essential Elements of a UML
Class Diagram
Class
Attributes
Operations
Relationships
Associations
Generalization
Specialization
Aggregation
Analysis and Design Information System – MTI Fasilkom 2007
Classes
Templates for creating instances or objects
Types of class
Concrete (has objects)
Abstract
Another types: the type of real-world thing that it
represents
Application domain, user interface, data structure, file
structure, operating environment, document, and
multimedia classes
Analysis and Design Information System – MTI Fasilkom 2007
Attributes
units of information relevant to the description of
the class
include only those attributes that are relevant to
the current application
“size” for a TV object is not necessary if the application is
concerned only with connections between TV and other
objects
do not attempt to include every attribute at the
beginning
more attributes can be added when the model is iterated
iteration of the model occurs almost at all times, particularly
for large projects
Analysis and Design Information System – MTI Fasilkom 2007
Attributes (Cont)
Avoid derivable attributes; instead, create a
function to derive each such attribute
“age” can be derived from “birthday” and
“current-date”
“total” of all transactions can be dynamically
computed when necessary, rather than storing it
somewhere
“discount price” can be computed using
current-price and discount factor
Analysis and Design Information System – MTI Fasilkom 2007
Operations
The behavior of the class will be defined
Action that instances/objects can take
Analysis and Design Information System – MTI Fasilkom 2007
Relationships
Generalization
Enables inheritance of attributes and operations
Ex:
A CUSTOMER class and an EMPLOYEE class can
be generalized into a PERSON class by extracting
the attributes and operations in common
It is represented with the a-kind-of relationship
Analysis and Design Information System – MTI Fasilkom 2007
Cont..
Generalization(bottom-up approach)
Motivated by identifying similarities and
common features among classes
“Part-time Instructor” derived from “Instructor” and
“Student” while modeling a department
“User” derived from “Customer”, “Bank Manager”
and “Teller” while modeling an ATM system
“Material” derived from “Book”, “Journal” and
“Magazine” while modeling a library catalog system
Analysis and Design Information System – MTI Fasilkom 2007
Cont..
We can use “specialization” (top-down
approach)
“Employee” become “ Secretary”,
“Engineer”
“ Student” become “Full-time Student”,
“Part-time Student”
“TV” become “Plasma TV”, “Flat Panel
TV”
Analysis and Design Information System – MTI Fasilkom 2007
Relationships (Cont..)
Aggregation
Relates parts to wholes
A part of or has parts
A door is a part of a car
An employee is a-part of a department
Association
Miscellaneous relationships between classes
A patient – an appointment
Analysis and Design Information System – MTI Fasilkom 2007
Identify as association if it is not clear
whether it is association or aggregation
“Mail” has “Address”
“Mail” uses “Address” for delivery
“Customer” has “Address”
“Customer” resides at “Address”
“TV” includes “Screen”
“TV” sends information to “Screen”
“Customer” is a “Users”
Analysis and Design Information System – MTI Fasilkom 2007
Identify as association if it is not clear
whether it is association or aggregation
“Mail” has “Address” (aggregation)
“Mail” uses “Address” for delivery (association)
“Customer” is a “Users”
(generalization/specialization)
Analysis and Design Information System – MTI Fasilkom 2007
Deriving components of a class
diagram from a usecase diagram
Actors are potential candidates for classes
Sometimes, an actor may not be modeled as a
class
Generalization or specialization between
actors will end up in generalization or
specialization relationship between the
corresponding classes
Analysis and Design Information System – MTI Fasilkom 2007
Two actors will be related if they are
connected through a series of use cases
The classes corresponding to these actors will
thus have an association
The ATM example – the actor “User” is related
to “Account” because of the use cases “deposit”
and “update account”
Analysis and Design Information System – MTI Fasilkom 2007
Your Turn
What classes, attributes, and operations that would
be required to describe a library system?
An librarian
name, birthdate, sex, etc
create_account, update, etc
A book
title, author, publisher, etc
loaned, lost, etc
A catalogue
Analysis and Design Information System – MTI Fasilkom 2007
CLASS-RESPONSIBILITY-
COLLABORATION CARDS
Analysis and Design Information System – MTI Fasilkom 2007
Responsibilities
Knowing responsibilities are those things
that an instance of a class must be capable
of knowing.
An instance of a class typically knows the
values of its attributes and its relationship
Doing responsibilities are those things that
an instance of a class must be capable of
doing
An instance of a class can execute its operations
Analysis and Design Information System – MTI Fasilkom 2007
Collaboration
Objects working together to service a request
Collaborations allow the analyst to think in terms of clients,
servers, and contracts
A client object is an instance of a class that sends a request to an
instance of another class for an operation to be executed.
A server object is the instance that receives the request from the client
object.
A contract formalizes the interactions between the client and server
objects.
For example, a patient makes an appointment with a doctor.
This sets up an obligation for both the patient and doctor to appear at the
appointed time. Otherwise, consequences, such as billing the patient for
the appointment regardless of whether the patient appears, can be dealt
out. The contract should also spell out what the benefits of the contract
will be, such as a treatment being prescribed for whatever ails the patient
and a payment to the doctor for the services provided.
Analysis and Design Information System – MTI Fasilkom 2007
A CRC Card
Analysis and Design Information System – MTI Fasilkom 2007
Back of CRC Card
Analysis and Design Information System – MTI Fasilkom 2007
CLASS DIAGRAMS
Analysis and Design Information System – MTI Fasilkom 2007
Class diagram – basic syntax
Association Class name
Class name
name
Attributes Attributes
Methods
aggregation Component
Class name
This is a
Attributes subclass
Methods
comments
Analysis and Design Information System – MTI Fasilkom 2007
Details of a class icon
Account
Initial value
- Account number : Integer
- Balance : Real
- Overdraft : Boolean = true
+ GetAccountId ()
+ public # UpdateBalance (sign : Sign, amt :
- private Integer)
# protected - ChangeOverdraft ()
Analysis and Design Information System – MTI Fasilkom 2007
Association –syntax
Association label Direction of association
customer uses
User Account
1 Account number
n
Manager Balance
1
cardinality Overdraft
Get accountID ()
Role names
Update balance()
{xor} Return balance()
us
Unary association
es
Corporate Account
n
Analysis and Design Information System – MTI Fasilkom 2007
Association Class
User Account
Transaction
Employee Job
Salary
Analysis and Design Information System – MTI Fasilkom 2007
Association Class
A piece of information that belongs to both classes in an
association is put into a separate class called “association
class”
association class is a dependent class that depends on the other two
classes in the association
cannot exist independently
object of an association class must refer to objects of the other two
classes in the association
Example: A “Transaction” object depends on a “User” object and on
an “Account” object.
Analysis and Design Information System – MTI Fasilkom 2007
Example Class Diagram
Analysis and Design Information System – MTI Fasilkom 2007
Class Diagram Syntax
A CLASS Class 1
-attribute
+operation ()
AN OPERATION
operation name ()
AN ASSOCIATION
1..* 0..1
______verb phrase____
Analysis and Design Information System – MTI Fasilkom 2007
UML suggest for the class name
Start with a capital letter
Be centered in the top compartment
Analysis and Design Information System – MTI Fasilkom 2007
More on Attributes
Derived attributes
/age, for example can be calculated from birth
date and current date
Visibility
Public (+)
Protected (#)
Private (-)
Analysis and Design Information System – MTI Fasilkom 2007
More on Operations
Constructor
Creates object
Query
Makes information about state available
Update
Changes values of some or all attributes
Analysis and Design Information System – MTI Fasilkom 2007
More on Relationships
Mean the relationship between one class with
another
Multiplicity of relationship
exactly one: 1
zero or more: 0..*
one or more: 1..*
zero or one: 0..1
specified range: 2..4
multiple disjoint ranges: 1..5,7
Association class
Analysis and Design Information System – MTI Fasilkom 2007
Multiplicity of relationship
Analysis and Design Information System – MTI Fasilkom 2007
Simplifying Class Diagrams
When a class diagram is fully populated with all of the
classes and relationships, it become very complex and
difficult to interpret
The view mechanism shows a subset of information
View based on a particular use case
View based on the relationship only or a particular relationship
only (such as association)
View based on subset of information such as class name only,
attributes only, or operations only
Packages show aggregations of classes (or any elements in
UML)
Analysis and Design Information System – MTI Fasilkom 2007
Object Diagrams
Analysis and Design Information System – MTI Fasilkom 2007
CREATING CRC CARDS AND
CLASS DIAGRAMS
Analysis and Design Information System – MTI Fasilkom 2007
Object Identification
1. Textual analysis of use-case information
Nouns suggest classes
Verbs suggest operations
To identify:
Object
Attribute
Operation
Relationship
Creates a rough first cut
Analysis and Design Information System – MTI Fasilkom 2007
Textual Analysis Guideline
Analysis and Design Information System – MTI Fasilkom 2007
Object Identification
2. Common object list
Physical/tangible (books, chairs)
Incidents (meetings, flight)
Analysis and Design Information System – MTI Fasilkom 2007
Object Identification
Pattern
Useful groupings of classes that recur in
various situations
Transactions
Transaction class
Item class
Location class
Participant class
Analysis and Design Information System – MTI Fasilkom 2007
Steps for Object Identification and
Structural Modeling
1. Create CRC cards by performing textual analysis on the use-cases.
Analysis and Design Information System – MTI Fasilkom 2007
Application
Example:
Analysis and Design Information System – MTI Fasilkom 2007
Step 1. Create CRC cards by performing
textual analysis on the use-cases
Textual Analysis: Nouns suggest classes
Analysis and Design Information System – MTI Fasilkom 2007
Step 1. Create CRC cards by performing
textual analysis on the use-cases
Textual Analysis: Nouns suggest classes
• Textual Analysis Results: Identified potential classes
Customer
Search Request
CD
CD List
Review (i.e., CD review information)
If further analyse the Maintain Order and Checkout use
cases, further potential classes will be identified such as
Order
Order Item
Credit card centre
etc
Analysis and Design Information System – MTI Fasilkom 2007
Step 1. Create CRC cards by performing
textual analysis on the use-cases
Textual Analysis: Verbs suggest operations:
• For each identified class, check the related verbs to identify the operations as well
as the relationships with other classes
Analysis and Design Information System – MTI Fasilkom 2007
Step 1. Create CRC cards by performing
textual analysis on the use-cases
Textual Analysis: Verbs suggest operations:
• Textual Analysis Result: For Customer Class, the identified operations (i.e.,
Responsibilities) and the relationship with other classes (i.e., Collaborators)
are
Analysis and Design Information System – MTI Fasilkom 2007
Step 1. Create CRC cards by performing
textual analysis on the use-cases
• Textual Analysis Result: Combine “nouns and verbs” analysis, the
back of “Customer class” CRC Card can be
Analysis and Design Information System – MTI Fasilkom 2007
Step 4. Create the Class Diagram based
on the CRC Cards
Analysis and Design Information System – MTI Fasilkom 2007
Step 4. Create the Class Diagram based
on the CRC Cards
• Solution:
Credit Card Centre
Order
Customer 0..*
1
-First name
0..* place ->
-Middle initial
Check -> 0..* -Last name
-……
+Make search req()
+Place order()
+Get credit info() Search Reg
+Exit()
0..* 0..*
Make ->
Analysis and Design Information System – MTI Fasilkom 2007
Step 5, 6 and 7: Review Classes Diagrams,
Incorporate Patterns, and Review the Model
1. Review the class diagrams and structural model
for any missing and/or redundancy
2. Incorporate useful patterns.
• One possible pattern
Analysis and Design Information System – MTI Fasilkom 2007