Professional Documents
Culture Documents
OOM Module 4
OOM Module 4
Design Class Diagrams extends the Domain Class Diagram Model that was
developed during Requirements Activities.
Divide Objects into different groups for that purpose is called ‘Multilayer Design’.
◘ Object groups:- User Interface Objects
Problem Domain Objects
Database Objects
The most important diagrams in Design is a ‘System Sequence Diagram’ - or its first cousin
a Communication Diagrams. These diagrams describe the ‘Messages’ that are sent between
Objects.
Analyst extends the System Sequence Diagram by modifying the single :System Object to
include all of the interacting ‘User-Interface’, ‘Problem Domain’ and ‘Database Access’
Objects.
The other major Design Model is ‘Design Class Diagram’. The purpose is to document and
describe the ‘Programming Classes’ that will be built for the new System.
Design Class Diagrams are the end result of the Design process. They describe the set of
Classes needed for Programming Navigation between Classes, Attribute Names and
Properties.
Thus, Design Class Diagram is a summary of he final Design that was developed using
the Detailed Sequence Diagrams.
◘ The third step is to return the Design Class Diagram and develop Method
Names, Attributes, and Navigation Visibility based on information developed
during the Design of the Iteration Diagrams.
◘ Final Step is to partition the Design Class Diagram into related functions
using Package Diagrams
Design Class Diagram is more detailed version of the Domain Model Class
Diagram. We complete the Design Class Diagram by integrating information
from Interaction Diagrams and other Models.
Object-Oriented Analysis and Design and the Unified Process 13
Design Class Symbols
Since many different types of Design Classes will be identified during the
Design Process UML has a special notation called ‘Stereotype’ that allows
Designer to designate a special type of Class
• An Overloaded Method – is a Method that occurs more than once with the same Name
but with two or more different Parameter lists.
•Constructor Method is the Method that makes or creates new Objects for the Class.
(e.g. Constructor such as createStudent (name, address, major):Student
- In many Programming languages the Constructor Method is given the same name as the
Class Name.
- We use a Create Statement to follow more closely the Message Names used in
Interactions Diagram (i.e Sequence Diagram and Collaboration Diagram).
• Class-Level Method is a Method that is associated with a Class instead of with Objects of
the Class. Class Level Method is Underlined.
Classes can have Very low, low, medium and high Cohesion. Classes with High level of
Cohesion are most Desirable.
An example of a Medium Cohesion would be a Class that has closely related responsibilities , such as
“Maintain Customer Information’ and another task of “Maintaining Customer Account
Information”.
Two Highly Cohesive Class could be defined one Class to Maintain Customer Information and the
other class for Customer Account Maintenance.
1. Hard to maintain since they do many different functions and tend to be over sensitive to changes
within the system, suffering from ripple effect
2. Hard to be reused since they have many unrelated functions; thus does not make sense to re-use
them.
3. It is difficult to understand the Class since their functions are intertwined and their logic is complex.
The common solution to Classes with Low Cohesion is to divide a Class into several
highly Cohesive Classes, This Design concept is called “Separation of Class
Responsibilities”.
Object-Oriented Analysis and Design and the Unified Process 24
Developing the First-Cut Design Class Diagram
The ‘First-Cut Design Diagram” is developed by extending the Domain Model
Class Diagram in two steps:-
◘ Sequence Diagrams
◘ Communication Diagrams
Design can be done using either Sequence Diagram or Communication Diagram .This is a matter of
a Designer’s preference.
----------------------------------------------------------------------------------------------
It is important to note that The Interaction Diagrams like Design Class
Diagram, developed while Software Design, are not end in themselves.
Instead they represent the result of Design Decisions based on well
established Design Principles such as ‘Coupling’, ‘Cohesion’ and
‘Separation of Responsibilities’.
Object Responsibility is a Design Principle that indicates which Objects are responsible
for carrying out System Processing
Use Case Controller Serves as a collection point for incoming messages. It acts
as an Intermediary between the outside world and the internal system
e.g. A single Input Window object (User Interface layer) may need to send messages to several
Objects in Domain Layer. In that circumstance the Coupling between the Input Window
Object and the System would be very high. (as in Fig 8.1) By using a Single Use Case
Controller Object to handle all the Input messages the coupling could be reduced.
A Single Use Case could be defined for all Use Cases within the System. This would
result in Low Cohesiveness, since the set of responsibilities assigned to a single Use
Case Controller would be vary broad.
A Single Use Case could be defined for all Use Cases in a Subsystem with a set of
responsibilities assigned to it. (remember there could be many Subsystems in a System)
One Use Case Controller for each Use Case wit a set of specific responsibilities
◘ Creating several Use Cases Controllers would raise the Coupling between
the User Interface Classes and the Internal Classes, but it would result in
highly cohesive Classes with a defined set of responsibilities for each.
Sequence Diagrams are used to explain Object interactions and document Design
decisions.
A Systems Sequence Diagram (SSD) captures the interactions between the System
and the External world represented by Actors. The System is treated like a (“Black
box”) i.e. a Single Object.
A Detailed Sequence Diagram uses all of the same elements as an SSD including the
Input Message Syntax:
* [true / false condition] return-value:- message-name (parameter-list)
except that the :System Object is replaced by all of the Internal Objects and
Messages within the System
The first step is to select an Input Message from the Use Case and add it to
Sequence Diagram
The next step is to Determine which other Messages must be sent, and which
Objects should be the Source and Destination of each Message.
◘ Message can be directly sent from one Object to other Object providing that
there is a Navigation Visibility. Otherwise, Messages will be sent indirectly
via an Object(s) that has Navigation Visibility to the required Object.
Using a Use Case Controller as the Switchboard limits the overall Coupling
between the Domain Objects and the Environment.
The :Availability Handler Class also is highly Cohesive with only two primary
Responsibilities. (Receive Incoming messages from the External Environment
and return the System response to the Destination)
- To make an Item Inquiry Actor sends an Input Message (InquiryOnitem) containing Parameter list of
(CatalogId ProdId and Size)
-The Single Use Case Controller (:AvailabilityHandler) acts like switchboard, forwards the Input Messages to the
relevant Superior Object which has Navigations to Subordinate Objects.
- From the Design Class Diagram determine which other Objects required to process the Look-Up Item Availability Use
Case. :Catalog, :CatalogProduct, :ProductItem, and :InventoryItem.
-- The (:AvailabilityHandler) forwards the Input Message to the :Catalog .Object since the Catalog has a
Superior / subordinate relationship (Navigation Visibility) to :CatalogProduct, and :ProductItem objects to get
Description and the Price.
- However :Catalog does not have direct Navigation Visibility to :InventoryItem to get “quantity”. So it sends
another Message to ask help from :ProductItem in getting the Quantity from :InventoryItem since it has a direct
Navigation to it.
:Catalog collects all information and returns it to the (:AvailabilityHandler which send it back to the Actor.
- Note: The Activation Lifeline under :AvailabilityHandlerexe is the indication of “+InquiryOnitem “ Method
execution. The Acivation Lifeline under :Catalog Indicates the Execution of “+getDescription” Method and
“getPrice” Method.
Object-Oriented Analysis and Design and the Unified Process 38
Object-Oriented Analysis and Design and the Unified Process 39
Guidelines for First-Cut (Preliminary) Sequence Diagram Development
The following three steps will produce the Preliminary Sequence Diagram. Remember
that refinement and modifications to the Preliminary Sequence Diagram may be
necessary.
1. Take each Input Message and determine all of the Internal Messages that result
from each Input Message.
- 2. For each Input Message, Identify the complete set of Classes that will be
affected by that Message. Such Classes are those listed in the Use Case
Description either in the Preconditions or Postconditions for a Use Case () .
Also other Classes such as Creators of Objects for the Use Case that are updated
during the Use Case. These Classes should be included in the Design.
3. Flesh out the components for each Message. Add Iteration , True / False
conditions, Return Values and Passed Parameters.
Note :- Passed Parameters should be based on the attributes of the Domain Class Diagram . Return Values
Object-Oriented Analysis and Design and the Unified Process 40
and Passed Parameters can be attributes but they may also be objects from Classes.
Developing a Multilayer Design
The First-cut Sequence Diagram focuses only on the Class in the Domain Layer.
However, in Systems Design we must also Design the “User Interface Classes”
and the “Data Access Classes”.
In the early days of Interactive Systems and Graphical User Interface (GUI) Tools,
Software Vendors invented Languages and Tools (early version of VB, Delphi etc) that
made it easy to develop Systems with GUI such as windows and buttons.
However in these Languages the Program Domain Logic was attached to the
Windows and other Graphical components. So to move these Systems to other
environments such as Browser-based Systems, Designers had to completely rewrite
the System.
Remember too that when a Class contains both User Interface Function and Business
Logic Function:’ the Class Cohesiveness becomes low!!!.
As O-O Languages become more prevalent and tools integrated both O-O Programs and
GUI, it becomes easier to build Systems that could be partitioned and that allowed Class
Responsibilities to be separated. Such as the User Interface Classes do not need to have
Business Logic – other than Edits on the Input Data).
So, Designers Could build Multilayer Systems that were more robust and easier
to maintain and conform with good Design. Tools such as JAVA and Visual Studio (.NET)
provide the capability to easily build GUI as well as sophisticated Problem Domain Classes.
Object-Oriented Analysis and Design and the Unified Process 41
Developing a Multilayer Design
Designing The View layer
The View Layer involves Human Computer Interaction (HCI) and requires
designing the User Interface for each Use Case.
The Designer takes the step in a Use Case Description and begins to develop a
Dialog Design for the Use Case , Usually defining one or more Window
Forms or Web Forms that the User will use to interact with the System.
Once the Electronic Forms are designed an Object-Oriented Window Class can
be defined for each Form
Since the Data are entered by the Actor via keyboard and the User Interface
Window Object catches that information, formats it and transmits the Message
to the Use Case Controller Object, the User Interface Object is placed between
the “Actor” and the “Use Case Controller” Object.
Object-Oriented Analysis and Design and the Unified Process 42
Developing a Multilayer Design
Designing the Data Access Layer
On Smaller Systems “Two Layer Design’’ exist, in which the SQL Statements to access a Database are
embedded within the Business Logic Layer. This implies that SQL statements are included in Methods of
the Problem Domain Classes.
On Large and more complex Systems , it makes sense to create Classes whose sole responsibilities is to
execute Database SQL Statements, get the results of query and provide that information to the Domain
Layer.
Rather than mixing the Business Logic with the Data Access Logic, it is better to define
separate Classes and let each Class to focus on its Primary Responsibility is an
application of Good Design principles of Highly Cohesive Classes with appropriate
Responsibilities.
Notes:- Description of each Domain Object has a prefix of (aX) identifie, where (X) is replaced by
the first character of Class. Eg. aC:Catalog and the Data Access Classes have Suffix of (DA).
e.g. aC:Catalog , aP:Product and :CatalogDA. Etc
The set of ‘’initxxxx’’ messages ( initCatalog , initProduct etc ) can either create a new Object if
necessary or simply verify that existing Objects are in memory.
Object-Oriented Analysis and Design and the Unified Process 43
Completed Three-Layer Design for Look up Item Availability
Object-Oriented Analysis and Design and the Unified Process 44
A First-Cut Sequence Diagram for an RMO Telephone Order
Define a User Controller Object (:OrderHandler)
Define a “Create Message’’ for new Order Objects which will create a new Object
within Order.
When a ‘Create Message’’ is sent to an Object, it is often drawn directly to the Object
box and not to the Lifeline (Optional Diagramming technique).
Another way is let the Customer Object create the Order Object. Since Order Object
are not allowed unless a Customer Object exist. This is one way to ensure that the
Customer existence Precondition.
◘ Note that a specific Identifier (anOrd) is given to the newly created Order Object
e.g. anOrd:Order,. The (anOrd Identifier is then passed back to the Customer Object,
which in turn passes it back to :OrderHandler
Define other Internal Messages along with Source and Destination as well as passed
Parameters and Navigation Visibility for each Message.
addItem (), createOrdItem (), getDescription(), getPrice(), updateQty ()
Working with Design Models enable the Designer to think through all the requirements to
process a Use Case without having to worry about code.
Object-Oriented Analysis and Design and the Unified Process 45
SSD for the Telephone Order Scenario of the Create new order Use Case
Object-Oriented Analysis and Design and the Unified Process 46
Sequence
Object-OrientedDiagram
Analysis andfor Telephone
Design Order
and the Unified ProcessScenario of Create New Order Use Case
47
Developing a Multilayer Design for the Telephone Order Scenario
Extend one Message at a time
View Layer
Data Layer
Despite the fact that the Sequence Diagrams may get somewhat
busy and complicated yet, they provide an excellent foundation for
Programming the Use case.
You can mix the usage of both Interaction Diagrams within the same set of specifications.
Since every Class must have Constructor, Get and Set methods it is optional to include
these in the Design Class.
However the Use Case Specific Methods must be included in the Design Class Diagram
For Every Class in the Domain Layer including the Use Case
Controller Classes we identify the Messages and ‘Create Methods’.
To develop Package Diagram extract information from Updated Design Class Diagram
and Interaction Diagram (Sequence Diagram) for each Use Case.
Place the Classes inside the appropriate Packages based on the Layer or Subsystem to
which they belong.
The Benefit of using the Package Diagrams for Documentation is that different
Packages can be assigned to different Programming teams to program the
Classes.
Over the last few years powerful Integrated Development Environment Tools (IDE)
have been developed to help Programmers construct the Systems.
The IDE tools provide a very high level of Programming support especially in the
construction of the new View Layer Classes ( Windows and Window Components of the
System).
Unfortunately some of these IDE Tools propagate some bad Programming habits in
the Developers since they:-
Contain Database Engines, to allow the building of the entire System with only
one Class.
Creates Window Classes with Programming Codes automatically inserted in the
Window Class
Object-Oriented Analysis and Design and the Unified Process 64
IMPLEMENTATION ISSUES FOR THREE-LAYER DESIGN
The Problem with IDE Tool approach is the difficulty of maintaining the System
Codes since they scattered throughout the Graphical Use Interface (GUI)
Classes, that becomes very hard to find and maintain.
-If a Network-based System needs to be enhanced to include Web- front end then a
Programmer must rebuild nearly the entire System.
-If two User Interfaces are desired , then all of the Business Logic is programmed
twice.
However without the IDE tool that generates code, it is almost impossible to keep
the
System current. This problem is exacerbated by new releases of the IDE tools
which
may not be compatible with earlier version. Many Programmers had to rewrite the
Front end of Systems because of new IDE Tool releases
We recommend that the would be Analysts and Programmers should use Good Design
Principles in the Development of new Systems
- For example given the Design Principles of Object Responsibility it is possible to define what
program responsibilities belong to each System Layer.
- If you follow
Object-Oriented these
Analysis andguidelines
Design and in
thewriting Program code, the new System will be much more 65
Unified Process
IMPLEMENTATION ISSUES FOR THREE-LAYER DESIGN
THE PRIMARY RESPONSIBILITIES OF EACH LAYER