CH10: Object Oriented Systems Analysis and Design Using UML CRC Cards and Object Think
§ CRC
Object-Oriented Analysis and Design o Class
§ Works well in situations where complicated systems are o Responsibilities
undergoing continuous maintenance, adaptation, and design o Collaborators
§ Objects, classes are reusable § CRC cards are used to represent the responsibilities of
§ The Unified Modeling Language (UML) is an industry standard classes and the interaction between the classes
for modeling object-oriented systems.
§ Reusability Interacting during a CRC Session
o Recycling of program parts should reduce the costs § Identify all the classes you can
of development in computer-based systems § Create scenarios
§ Maintaining systems § Identify and refine responsibilities
o Making a change in one object has a minimal impact
on other objects The Unified Modeling Language (UML) Concepts and Diagrams
• Things
Object-Oriented Concepts • Relationships
• Objects • Diagrams
• Classes
• Inheritance Things
§ Structural things are:
Objects o Classes, interfaces, use cases, and other
§ Persons, places, or things that are relevant to the system elements that provide a way to create models
being analyzed o They allow the user to describe relationships
§ May be customers, items, orders, and so on § Behavioral things
§ May be GUI displays or text areas on a display § Describe how things work
o Interactions and state machines
Classes § Group things
§ Defines the set of shared attributes and behaviors found in o Used to define boundaries
each object in the class § Annotational things
§ Should have a name that diNerentiates it from all other o Can add notes to the diagrams
classes
§ Instantiate is when an object is created from a class Relationships
§ An attribute describes some property that is possessed by all § Structural relationships
objects of the class o Tie things together in structural diagrams
§ A method is an action that can be requested from any object § Behavioral relationships
of the class o Used in behavioral diagrams
An Example of a UML Class: A Class Is Depicted as a Rectangle Structural Relationships
Consisting of the Class Name, Attributes, and Methods • Dependencies
• Aggregations
• Associations
• Generalizations
Behavioral Relationships
• Communicates
• Includes
• Extends
• Generalizes
Inheritance Diagrams
§ When a derived class inherits all the attributes and behaviors • Structural diagrams
of the base class o Used to describe the relation between classes
§ Reduces programming labor by using common objects easily • Behavior diagrams
§ A feature only found in object-oriented systems o Used to describe the interaction between
people (actors) and a use case (how the actors
A Class Diagram Showing Inheritance use the system)
Car and truck are specific Structural Diagrams
examples of vehicles and • Class diagrams
inherit the characteristics of • Object diagrams
the more general class • Component
vehicle. diagrams
• Deployment
diagrams
Behavioral Diagrams
• Use case diagrams
• Sequence diagrams
• Collaboration
diagrams
• Statechart diagrams
• Activity diagrams
An Overall View of UML and Its Components: Things,
Relationships, and Diagrams
Creating Activity Diagrams
§ Created by asking what happens first, what happens second,
and so on
§ Must determine what activities are done in sequence or in
parallel
§ The sequence of activities can be determined from physical
data flow diagrams
§ Can be created by examining all the scenarios for a use case
Swimlanes
§ Useful to show how the data must be transmitted or
converted
§ Help to divide up the tasks in a team
§ Makes the activity diagram one that people want to use to
Commonly Used UML Diagrams communicate with others
§ Use case diagram
o Describing how the system is used Activity Diagrams and Test Plans
o The starting point for UML modeling § Activity diagrams may be used to construct test plans
§ Use case scenario § Each event must be tested to see if the system goes to the
o A verbal articulation of exceptions to the main next state
behavior described by the primary use case § Each decision must be tested
§ Activity diagram
o Illustrates the overall flow of activities Activity Diagrams Not Created for All Use Cases
§ Sequence diagrams § Use an activity diagram when:
o Show the sequence of activities and class o It helps to understand the activities of a use case
relationships o The flow of control is complex
§ Class diagrams o There is a need to model workflow
o Show classes and relationships o When all scenarios for a use case need to be shown
§ Statechart diagrams
o Show the state transitions Sequence Diagrams
§ Illustrate a succession of interactions between classes or
Use Case Modeling object instances over time
§ Describes what the system does, without describing how the § Often used to show the processing described in use case
system does it scenarios
§ Based on the interactions and relationships of individual use § Used to show the overall pattern of the activities or
cases interactions in a use case
§ Use case describes
o Actor Specialized Symbols Used to Draw a Sequence Diagram
o Event
o Use case
A Use Case Scenario Is Divided into Three Sections:
• Identification and Initiation
• Steps Performed
• Conditions, Assumptions, and Questions
Activity Diagrams
§ Show the sequence of activities in a process, including
sequential and parallel activities, and decisions that are
made
§ Symbols
o Rectangle with rounded ends
o Arrow
o Diamond
o Long, flat rectangle
o Filled in circle
o Black circle surrounded by a white circle
o Swimlanes
Communication Diagrams Interface or Boundary Classes
§ Describes the interactions of two or more things in the system § Provide a means for users to work with the system
that perform a behavior that is more than any one of the things § Human interfaces may be a display, window, Web form,
can do alone dialogue box, touch tone telephone, or other way for users to
§ Shows the same information as a sequence diagram, but may interact with the system
be more diNicult to read § System interfaces involve sending data to or receiving data
§ Emphasizes the organization of objects from others
§ Made up of objects, communication links, and the messages
that can be passed along those links Abstract Classes
§ Linked to concrete classes in a generalization/specialization
A Communication Diagram for Student Admission relationship
§ Cannot be directly instantiated
Control Classes
§ Used to control the flow of activities
§ Many small control classes can be used to achieve classes
that are reusable
Presentation, Business, and Persistence Layers
§ Sequence diagrams may be discussed using three layers:
o Presentation layer, what the user sees, corresponding to
§ Communication diagrams show the same information that is the interface or boundary classes
depicted in a sequence diagram but emphasize the o Business layer, containing the unique rules for this
organization of objects rather than the time ordering. application, corresponding roughly to control classes
o Persistence or data access layer, for obtaining and
Class Diagrams storing data, corresponding to the entity classes
§ Show the static features of the system and do not represent
any particular processing Defining Messages and Methods
§ Show the nature of the relationships between classes § Each message may be defined using a notation similar to that
§ Show data storage requirements as well as processing described for the data dictionary
requirements § The methods may have logic defined using structured
English, a decision table, or a decision tree
§ Classes
§ Attributes Create Sequence Diagrams
o Private § Include the actor from the use case diagram
o Public § Define one or more interface classes for each actor
o Protected § Each use case should have one control class
§ Methods § Examine the use case to see what entity classes are required
o Standard § The sequence diagram may be modified when doing detailed
o Custom design
A Class Diagram for Course ORerings: The Filled In Diamonds Creating a Test Plan from a Sequence Diagram
Show Aggregation and the Empty Diamond Shows a Whole Part § Does each method return correct results?
Relationship § Ensure that entity classes store or obtain the correct attribute
values
§ Verify that all JavaScript paths work correctly
§ Ensure that the server control classes work correctly
§ Ask, “What may fail?”
§ Determine what to do if something can fail
Relationships
§ The connections between classes
o Associations
o Whole/part
An Example of an Associative Class in Which a Particular
Section Defines the Relationship between a Student and a
Course
Method Overloading
§ Including the same method (or operation) several times in a
class
§ The same method may be defined more than once in a given
class, as long as the parameters sent as part of the message
are diNerent
Types of Classes
• Entity classes
• Interface classes
• Abstract classes
• Control classes
Entity Classes
§ Represent real world items
§ The entities represented on an entity relationship diagram
Associations Polymorphism
§ The simplest type of relationship § The capability of an object-oriented program to have several
§ Association classes are those that are used to break up a versions of the same method with the same name within a
many to many association between classes § superclass/subclass relationship
§ An object in a class may have a relationship to other objects § The subclass method overrides the superclass method
in the same class, called a reflexive association § When attributes or methods are defined more than once, the
most specific one is used
Whole/Part Relationships
§ When one class represents the whole object, and other Abstract Classes
classes represent parts § Abstract classes are general classes
§ Categories § No direct objects or class instances, and is only used in
o Aggregation conjunction with specialized classes
o Collection § Usually have attributes and may have a few methods
o Composition
A Generalization/Specification Diagram Is a Refined Form of a
Aggregation Class Diagram
§ A “has a” relationship
§ Provides a means of showing that the whole object is
composed of the sum of its parts
Collection
§ Consists of a whole and its members
§ Members may change, but the whole retains its identity
§ A weak association
Composition
§ The whole has a responsibility for the parts, and is a stronger
relationship
§ If the whole is deleted, all parts are deleted
An Example of Whole Part and Aggregation Relationships
Finding Classes
§ During interviewing or JAD sessions
§ During facilitated team sessions
§ During brainstorming sessions
§ Analyzing documents and memos
§ Examining use cases, looking for nouns
Determining Class Methods
§ Standard methods
§ Examine a CRUD matrix
Messages
Generalization/Specialization Diagrams
§ Used to send information by an object in one class to an
• Generalization object in another class
• Inheritance § Acts as a command, telling the receiving class to do
• Polymorphism something
• Abstract classes § Consists of the name of the method in the receiving class, as
• Messages well as the attributes that are passed with the method name
§ May be thought of as an output or an input
Generalization
§ Describes a relationship between a general kind of thing and Statechart Diagrams
a more specific kind of thing § Used to examine the diNerent states that an object may have
§ Described as an “is a” relationship § Created for a single class
§ Used for modeling class inheritance and specialization o Objects are created, go through changes, and are
§ General class is a parent, base, or superclass deleted or removed
§ Specialized class is a child, derived, or subclass § Objects
§ States
Inheritance § Events
§ Helps to foster reuse o Signals or asynchronous messages
§ Helps to maintain existing program code o Synchronous
o Temporal events
§ Created when:
o A class has a complex life cycle
o An instance of a class may update its attributes in a
number of ways through the life cycle
o A class has an operational life cycle
o Two classes depend on each other
o The object’s current behavior depends on what
happened previously
Packages
§ Containers for other UML things
§ Show system partitioning
§ Can be component packages
§ Can be physical subsystems
§ Use a folder symbol
§ May have relationships
Use Cases Can Be Grouped into Packages
Putting UML to Work
§ The steps used in UML are:
o Define the use case model
o Continue UML diagramming to model the system
during the systems analysis phase
o Develop the class diagrams
o Draw statechart diagrams
o Begin systems design by refining the UML diagrams
o Document your system design in detail
Summary
§ Object-oriented systems
o Objects
o Classes
o Inheritance
§ CRC cards
§ UML and use case modeling
§ Components of UML
o Things
o Relationships
o Diagrams
§ UML diagrams
o Use case diagrams
o Activity diagrams
o Sequence diagrams
o Communication diagrams
o Class diagrams
o Statechart diagrams
§ • Using UML