Академический Документы
Профессиональный Документы
Культура Документы
Design
Class Identification and Class
Diagrams
Objects
In object oriented analysis, the world is modeled
in objects.
Objects are entities that have a well-defined role
within the system.
An object can be tangible or visible (i.e. person,
place or thing) or a concept of event (department,
registration, etc.) or an artifact of the design
process (user interface, scheduler, etc.).
Objects are nouns.
Object Properties
Objects are described both by their properties
(attributes and relationships) and by their behavior
(how the object acts and reacts).
Objects represent categories while an object
instance is a specific occurrence of the object.
To remove any confusion, some texts use the
terminology object class to refer to the set of
objects.
Object Defined
An object is an entity which has a state and a defined set of
operations which operate on that state. The state is represented
as a set of object attributes. The operations associated with the
object provide services to other objects (clients) which request
these services when some computation is required. Objects are
created according to some object class definition. An object
class definition serves as a template for objects. It includes
declarations of all the attributes and services which should be
associated with an object of that class.
Ian Summerville, Software Engineering, 2000
Object Encapsulation
Object encapsulation is the term used to describe the
representation of objects by their attributes and behavior.
It is important to remember that an object is "solely
responsible for carrying out any functions or behaviors that
act on its own data."
The internal workings of an object are private - other
objects can see only the interface.
You should also note that the attributes of an object can be
other objects and the behavior of an object can use other
objects.
Object Classification
Objects are represented by classification and
class hierarchies. Several principles relate to
this process. These include:
Understanding Classes
A class is a collection of objects with a common
structure, common behavior, common relationships
and common semantics.
class name: noun representing the class domain.
attributes: characteristics of the class - identified by
examining class definitions, problem requirements and
domain knowledge - current attribute values define an
object's state.
behaviors: represents operations and functions and are
found by examining object interactions
Object Identification
Identifying objects is the most difficult part of
object oriented design.
There is no 'magic formula' for object
identification. It relies on the skill, experience .
and domain knowledge of system designers.
Object identification is an iterative process. You
are unlikely to get it right first time.
Course
Attributes
Name
Number of
Credits
Methods
Open
AddStudent
Student
Name
StudentID
Year
...
Calc-age ()
Calc-gpa
Register for (course)
...
Index
User
Name
Name
UserID
File
Retrieve
Archive
Destroy
Display
Delete entry
Add entry
Get command
Put message
Retrieval
System
User command
Index
User
Name
Name
UserID
File
Retrieve
Archive
Destroy
Display
Delete entry
Add entry
Get command
Put message
Retrieval
System
User command
Operations
Operations are functions or services provided by all
instances of a class (calc-gpa, delete, display, etc.).
There are three types of operations:
Constructor creates a new instance of a class.
Query Accesses a state of an object but does not alter
the state.
Update it alters the state of an object.
Document
Index
Name
Name
File
Retrieve
Archive
Destroy
Display
Delete entry
Add entry
User
UserID
Get command
Put message
Retrieval
User command
A Word on Attributes
Visibility of attributes may be shown
Visibility relates to information hiding
+ public not hidden from any other object
# protected hidden from all classes except its
immediate subclass
- private hidden from all other classes
Document
+Name
File
Retrieve
Archive
Destroy
Index
+Name
Display
Delete entry
Add entry
User
UserID
Get command
Put message
Retrieval
User command
Perspective continued
Class Relationships
Relationships between classes are
discovered by examining interactions
between objects.
If two objects must 'talk,' there must be a
pathway for communication.
Types of Relationships
There are three primary types of relationships
Generalization enables inheritance of attributes and operations.
Shown as connecting lines with arrows
Association - a bi-directional connection between classes. Shown
as a line connecting related classes.
Aggregation - stronger from of relationship between a whole and
its parts. Shown as a line connecting the related classes with a
hollow diamond next to the class representing the whole.
Dependency - weaker form of relationship showing a relationship
between a client and a supplier where the client does not have a
semantic knowledge of the supplier. Shown as a dashed line
pointing from the client to the supplier.
Relationship Attributes/Operations
Some relationships
have attributes and
operations.
They are added as an
association class and
depicted with a dashed
line.
The association class
does not exist without
the original association.
Performer
Performance
Performance
Contract
/ total
service charge
delivery charge
facility charge
sales tax
name
addresss
credit card
area code
phone no.
calculate total()
sum purchase price()
receive payment ()
claculate change()
add item()
Charge
exiration date
account number
issuer
authorize credit ()
Aggregation
Aggregation - stronger from of relationship
between a whole and its parts. Shown as a line
connecting the related classes with a hollow
diamond next to the class representing the
whole.
A stronger form of aggregation is composition (depicted
with a solid diamond). Composition is used when a part
object belongs to only one whole object and lives and dies
with the whole object room in a building.
Adding Inheritance
Inheritance is a relationship between a
superclass and its subclasses.
There are two ways to find inheritance generalization and specialization.
Inheritance identifies common attributes,
operations and/or relationships and places
them at the highest level in the hierarchy.
Inheritance reduces redundancy and
improves efficiency.
Abstract
An abstract class is a class that has no direct
instances(Concrete class is a class that has
direct instances).
Examples include university students who must
be identified by their standing.The abstract
class is student but student does not have any
direct instances. Student descendants
Graduate and Undergraduate have instances.
Adding Multiplicity
Multiplicity is also shown between class relationships (as
is done with cardinality in ER diagrams).
Multiplicity defines how many objects participate in a
relationship. Multiplicity is bi-directional - one for each
end of the relationship. When thinking of multiplicity, you
define it as the number of instances of one class related to
the ONE instance of the other class.
While associations and aggregation are bi-directional by
default, is often desirable to restrict navigation to one
direction. If this is done, an arrowhead is added to indicate
the direction of the navigation.
Object Diagrams
A method used to quickly identify
relationships is the Object Diagram.
In its simplest form, an Object Diagram
depicts classes and their relationships to
other classes without adding detail.
The object diagram is used as a tool upon
which the Class Diagram can be built.
Rules continued
Modeling is iterative.
Sort out which perspective you are drawing
the models from.
If you are in analysis draw conceptual models.
When working with software concentrate on
specification models.
Draw implementation models only when you
are illustrating a particular implementation
technique.
Identifying Classes
Identifying objects/classes is the most difficult part of
OOAD.
There is no magic formula.
It relies on skill, experiences and knowledge of the system
domain.
It is an iterative process.
Objects/classes can be identified throughout the OOAD
process.
Object Identification
Textual analysis of use-case information
Nouns suggest classes
Verbs suggest operations
Creates a rough first cut
Common object list
Incidents
Roles
Patterns
Useful groupings of classes that recur in various
situations
Transactions
Transaction class
Transaction line item class
Item class
Location class
Participant class
PowerPoint Presentation for Dennis, Wixom & Tegardem
Systems Analysis and
Design
Copyright 2001 John Wiley & Sons, Inc. All rights reserved.
Typical examples:
Application domain
user interface
data structure
file structure
operating environment
Document
and multimedia classes
PowerPoint Presentation for Dennis, Wixom & Tegardem
Systems Analysis and
Design
Copyright 2001 John Wiley & Sons, Inc. All rights reserved.
Approaches to identification
A good place to start the identification of system
classes and objects is by analyzing use cases. You
can begin by simply finding all the nouns and then
assessing whether they really are an object or
simply an attribute.
Another commonly used technique relies on 'roleplay' to act out use cases. A class of objects is
identified and then what the class does and whom
it does it with are identified. The results are
reported on a Class Responsibility Collaboration
(CRC) card.
Collaborators
Collaborators
Course Offerings
Collaborators
Registrar
A CRC Card
Front:
Class name:
ID:
Type:
Description:
Responsibilities:
Collaborators:
Back:
Attributes:
Relationships:
Generalization (a-kind-of):
Aggregation (has-parts):
Other Associations:
PowerPoint Presentation for Dennis, Wixom & Tegardem
Systems Analysis and
Design
Copyright 2001 John Wiley & Sons, Inc. All rights reserved.
CRC Resources
For a description of how to play the CRC game
visit
http://members.aol.com/humansandt/techniques
/crc.htm
CRC Tutorial:
http://www.csc.calpoly.edu/~dbutler/tutorials/win
ter96/crc_b/
http://ftp.ics.uci.edu/pub/arch/uml/tours/bdClas
sDiagram.html