Object-Oriented Analysis & Design Guide
Object-Oriented Analysis & Design Guide
proceeding:
This document is confidential and intended solely for the educational purpose of RMK
Group of Educational Institutions. If you have received this document through email in
error, please notify the system manager. This document contains proprietary
information and is intended only to the respective group / learning community as
intended. If you are not the addressee you should not disseminate, distribute or copy
through e-mail. Please notify the sender immediately by e-mail if you have received this
document by mistake and delete this document from your system. If you are not the
intended recipient you are notified that disclosing, copying, distributing or taking any
action in reliance on the contents of this information is strictly prohibited.
21CS933-OBJECT ORIENTED ANALYSIS AND
DESIGN
Department: Computer Science & Engineering
Batch/Year:2021-2025/III Year
Created by: Dr.M.Vedaraj & Mr.Shanker
January 2024
1. CONTENTS
S. No. Contents
1 Contents
2 Course Objectives
3 Pre Requisites
4 Syllabus
5 Course outcomes
7 Lecture Plan
9 Lecture Notes
10 Assignments
12 Part B Questions
16 Assessment Schedule
Pre Requisites
Introduction to OOAD with OO Basics - Unified Process – UML diagrams – Use Case
– Class Diagrams– Interaction Diagrams – State Diagrams – Activity Diagrams
– Package, component, and Deployment Diagrams.
REFERENCES:
2.Simon Bennett, Steve Mc Robb and Ray Farmer, “Object Oriented Systems
Analysis and Design Using UML”, Fourth Edition, Mc-Graw Hill Education, 2010.
3.Erich Gamma, and Richard Helm, Ralph Johnson, John Vlissides, “Design
patterns: Elements of Reusable Object-Oriented Software”, Addison-Wesley,
1995.
4.Martin Fowler, “UML Distilled: A Brief Guide to the Standard Object Modeling
Language”, Third edition, Addison Wesley, 2003.
PSO3
PSO2
PSO1
4,K
5
PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO-
1 2 3 4 5 6 7 8 9 10 11 12
CO1 K3 2 1 1 - - - - - - - - - 2 2 2
CO2
K3 3 3 3 - - - - - - - - - 2 2 2
CO3
K3 3 3 3 - - - - - - - - - 2 2 2
CO4
K3 3 3 3 - - - - - - - - - 2 2 2
CO5
K3 3 3 3 - - - - - - - - - 2 2 2
Correlation Level:
1. Slight (Low)
2. Moderate (Medium)
3. Substantial (High)
If there is no correlation, put
“-“.
7. LECTURE PLAN
Structural – PPT/
5 Bridge 1 CO1 K2
Demo
Adapter -
PPT/
6 behavioural 1 CO1 K3
– Strategy – Demo
observer
8. Activity based learning(Factory Method)
E-book reference
1. Clean Code: A Handbook of Agile Software Craftsmanship
2. The Clean Coder: A Code of Conduct for Professional Programmers
3. Agile Software Development, Principles, Patterns, and Practices
4. UML for Java Programmers
5. Design Patterns: Elements of Reusable Object-Oriented Software
6. Object-Oriented Analysis and Design with Applications (3rd Edition)
7. Test Driven Development: By Example (Kent Beck)
8. Refactoring: Improving the Design of Existing Code: Martin Fowler also have a
Ruby version
9. Applying UML and Patterns: Craig Larman
UNIT II DESIGN PATTERNS
The different patterns and principles used in GRASP are: Information Expert,
Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication,
Indirection, Protected Variations. All these patterns answer some software problem,
and in almost every case these problems are common to almost every software
development project. These techniques have not been invented to create new ways
of working but to better document and standardize old, tried-and-testedprogramming
principles in object oriented design.
of an object include:
Patterns
In OO design, a pattern is a named description of a problem and solution that can
be applied to new contexts; Many patterns, given a specific category of problem,
guide the assignment of responsibilities to objects. For example, here is a sample
pattern
Creator Pattern
Creator:
The creation of objects is one of the most common activities in an object- oriented
system. Consequently, it is useful to have a general principle for assignment of
creation responsibilities. Assigned well, the design can support low coupling
increased clarity, encapsulation, and reusability.
UNIT II DESIGN PATTERNS
Problem:
Who should be responsible for creating a new instance of some class ?
Solution:
Assign class B the responsibility to create an instance of class A if one ormore of the
following is true :
B aggregates A objects .
B contains A objects.
B records instances of A objects.
B closely uses A objects.
B has the initializing data that will be passed to A when it is created
B is a creator of A objects.
Solution:
Since a Sate contains (in fact, aggregates) many SalesLineltem objects, the
Creator pattern suggests that Sale is a good candidate to have the responsibility
of creating SalesLineltem instances.
on creation.
Related Patterns
Low coupling
Information Expert
Information Expert
By Information expert we should look for the class of objects that has the
information needed to determine the total.
Example:
Problem: Who should be responsible for knowing the total price for a
sale?
Solution : Let Sale do it because it knows all of its SaleLineItems. For
example, to get the sale total, Sale gets subtotals from SaleLineItem
which get prices from Product Description.
We see that Sale already has the SalesLineItem objects needed to calculate
the total
UNIT II DESIGN PATTERNS
Expert benefits
Information encapsulation is maintained since obj. use their own info to fulfill
tasks. This usually supports low coupling, which leads to more robust and
maintainable systems.
Behavior is distributed across the classes that have the required info, thus
encouraging more cohesive ―lightweight‖ class definitions that are easier to
understand and maintain.
Related Patterns
Low coupling
High cohesion
Low Coupling.
Coupling is a measure of how strongly one element is connected to, has knowledge
of, or relies on other element. If there is coupling or dependency, then when the
depended-upon element changes, the dependent may be affected.
Problem: How to support a low dependency, low change impact ,and increased
reuse?
Solution:
Solution :
By Expert, let Register create Payment info, then associate it with the
Sale Register & Sale now coupled to Payment
Design:1
On the one hand, we might give Register the responsibility to create the
Payment:
Design :2
On the other hand, we might give Sale the responsibility to create the Payment:
Related Patterns
Protected Variation
High Cohesion
Cohesion measures how functionality related the operations of a software
elements are, and also measures how much work a software element is
doing.
Solution :
Assign responsibilities so that
cohesion remains high and object„s
responsibilities are closely related
Teamwork„
UNIT IIDESIGNPATTERNS
Example:
For the POS system, when we design for the makePayment() system operation:
We already saw that this creates an unnecessary coupling between Register and
Payment. But it also reduces the cohesion of Register.
By delegating Payment creation to Sale, we not only decrease coupling, but we also
increase the cohesion of Register.
Controller
Controller is the first obj. (class) beyond the UI layer that is responsible for receiving
or handling a system operation message.
The Controller pattern assigns the responsibility of dealing with system events
to a non-UI class that represent the overall system or a use case scenario. A
Controller object is a non-user interface object responsible for receiving or handling
a system event.
A use case controller should be used to deal with all system events of a use case,
and may be used for more than one use case (for instance, for use cases Create
User and Delete User, one can have one User Controller, instead of two separate
use case controllers).
It is defined as the first object beyond the UI layer that receives and coordinates
("controls") a system operation. The controller should delegate to other objects the
work that needs to be done; it coordinates or controls the activity. It should not do
much work itself.
UNIT II DESIGN PATTERNS
Problem:
The UI & domain layers should be loosely coupled. What is the 1st object should
receive and coordinate messages (system operation) between the UI layer and
other domain objects?
Solution :
Problem :Which object in the domain layer should be responsible for the system
operations?
Solution:
Select the ‗root„ object in the POS domain model (Store)
Controller benefits
Related Patterns
Command: In a msg handling sys., each msg may be represented and handled by
a spate Command obj
Façade
Layers (POSA pattern) placing domain logic in the domain layer.
Pure Fabrication
Design Patterns
Design patterns provide solutions to common software design problems. In the case
of object-oriented programming, design patterns are generally aimed at solving the
problems of object generation and interaction, rather than the larger scale problems
of overall software architecture. They give generalised solutions in the form of
templates that may be applied to real-world problems.
Creational Patterns
Structural Patterns
Behavioural Patterns
Command Object
Interpreter Class
Iterator Object
Mediator Object
Memento Object
Observer Object
State Object
Strategy Object
Template Class
Method
Visitor Object
UNIT II DESIGN PATTERNS
Creational Patterns
The first type of design pattern is the creational pattern. Creational patterns
provide ways to instantiate single objects or groups of related objects. There
are five such patterns:
Abstract Factory: The abstract factory pattern is used to provide a client with
a set of related or dependant objects. The "family" of objects created by the
factory are determined at run-time.
Builder : The builder pattern is used to create complex objects with constituent
parts that must be created in the same order or using a specific algorithm. An
external class controls the construction algorithm.
Singleton The singleton pattern ensures that only one object of a particular
class is ever created. All further references to objects of the singleton class refer
to the same underlying instance.
UNIT II DESIGN PATTERNS
Intent
Discussion
Provide a level of indirection that abstracts the creation of families of related or
dependent objects without directly specifying their concrete classes. The
"factory" object has the responsibility for providing creation services for the entire
platform family. Clients never create platform objects directly, they ask the
factory to do that for them.
This mechanism makes exchanging product families easy because the specific
class of the factory object appears only once in the application - where it is
instantiated. The application can wholesale replace the entire family of products
simply by instantiating a different concrete instance of the abstract factory.
UNIT II DESIGN PATTERNS
Example
The purpose of the Abstract Factory is to provide an interface for creating families of
related objects, without specifying concrete classes. This pattern is found in the sheet
metal stamping equipment used in the manufacture of Japanese automobiles. The
stamping equipment is an Abstract Factory which creates auto body parts. The same
machinery is used to stamp right hand doors, left hand doors, right front fenders, left
front fenders, hoods, etc. for different models of cars. Through the use of rollers to
change the stamping dies, the concrete classes produced by the machinery can be
changed within three minutes.
Factory
This is also called Simple Factory or Concrete Factory. This pattern is not a GoF
design pattern,
but extremely widespread. It is also a simplification of the GoF Abstract Factory pattern
and often described as a variation of Abstract Factory, although that's not strictly
accurate.
Solution: (advice) Create a Pure Fabrication object called a Factory that handles the
creation.
UNIT II DESIGN PATTERNS
UNIT II DESIGN PATTERNS
Without changing the source code in this factory class, can create instances of
new adapter classes by changing the property value and ensuring that the new
class is visible in the Java class path for loading.
Structural Patterns
The second type of design pattern is the structural pattern. Structural patterns
provide a manner to define relationships between classes or objects.
Adapter. The adapter pattern is used to provide a link between two otherwise
incompatible types by wrapping the "adaptee" with a class that supports the
interface required by the client.
Bridge .The bridge pattern is used to separate the abstract elements of a class
from the implementation details, providing the means to replace the implementation
details without modifying the abstraction.
UNIT II DESIGN PATTERNS
Adapter (GoF)
Name: Adapter
Example:
The NextGen POS system needs to support several kinds of external third- party
services, including tax calculators, credit authorization services, inventory
systems, and accounting systems, among others. Each has a different API, which
can't be changed.
Bridge
Name : Bridge
Problem : How to decouple an abstraction from its implemention so
that the two can vary independently.
Intent
Decouple an abstraction from its implementation so that the two can vary
independently.
Discussion
Decompose the component's interface and implementation into orthogonal class
hierarchies. The interface class contains a pointer to the abstract implementation class.
This pointer is initialized with an instance of a concrete implementation class, but all
subsequent interaction from the interface class to the implementation class is limited
to the abstraction maintained in the implementation base class. The client interacts
with the interface class, and it in turn "delegates" all requests to the implementation
class.
The interface object is the "handle" known and used by the client; while the
implementation object, or "body", is safely encapsulated to ensure that it may continue
to evolve, or be entirely replaced (or shared at run-time.
you have a proliferation of classes resulting from a coupled interface and numerous
implementations,
Consequences include:
Example
• The Bridge pattern decouples an abstraction from its implementation, so that the
two can vary independently. A household switch controlling lights, ceiling fans, etc.
is an example of the Bridge. The purpose of the switch is to turn a device on or off.
The actual switch can be implemented as a pull chain, simple two position switch,
or a variety of dimmer switches.
UNITIVDESIGNPATTERNS
UNIT II DESIGN PATTERNS
Behavioral patterns
Strategy (GoF)
Name: Strategy
Each getTotal method takes the Sale object as a parameter, so that the pricing
strategy object can find the pre-discount price from the Sale , and then apply the
discounting rule. The implementation of each getTotal method will be
different: PercentDiscountPricingStrategy will discount by a percentage, and so on.
A strategy object is attached to a context object the object to which it applies the
algorithm. In this example, the context object is a Sale . When a getTotal
message is sent to a Sale, it delegates some of the work to its strategy object. It
is not required that the message to the context object and the strategy object have
the same name, as in this example (for example,getTotal and getTotal ), but it
is common. However, it is common indeed, usually required that the context object
pass a reference to itself (this ) on to the strategy object, so that the strategy has
parameter visibility to the context object, for
further collaboration.
UNIT II DESIGN PATTERNS
When a Sale instance is created, it can ask the factory for its pricing strategy
3. When the SaleFrame1 window is initialized, pass it the Sale instance from which
it is displaying the total.
5. Note that the Sale does not know about SaleFrame1 objects; rather, it only knows
about objects that implement the Property Listener interface. This lowers the
coupling of the Sale to the window the coupling is only to an interface, not to a
GUI class.
6. The Sale instance is thus a publisher of "property events." When the total
changes, it iterates across all subscribing Property Listeners
, notifying each.
The SaleFrame1 object is the observer/subscriber/listener. it subscribes to interest
in property events of the Sale , which is a publisher of property events. The Sale
adds the object to its list of Property Listener subscribers. Note that the Sale does
not know about the SaleFrame1 as a SaleFrame1 object, but only as a Property
Listener object; this lowers the coupling from the model up to the view layer.
UNIT II DESIGN PATTERNS
As illustrated when the Sale total changes, it iterates across all its registered
subscribers, and "publishes an event" by sending the onPropertyEvent message to
each.
UNIT II DESIGN PATTERNS
• Method definitions
DCDs contain class or interface names, classes, method and simple attributes.
Reference Attributes:
Role Names:
Order of implementation
UNIT II DESIGNPATTERNS
Class Register
UNIT II DESIGN PATTERNS
UNIT II DESIGN PATTERNS
10. Assignments ( For higher level learning and
Evaluation - Examples: Case study, Comprehensive
design, etc.,)
Category I:
Consider the scenario where a Funds Transfer operation must be supported
by an ATM, over Net Banking application, as well as in-person by a Cashier
from a Bank branch location. Which GRASP principle can best guide the
assignment of this responsibility? Explain in detail. (C02,K4)
Category II:
Design a class diagram for a university course management system. Apply
the Information Expert pattern to determine which class should be
responsible for calculating the GPA of a student. (C02,K4)
Category III:
Develop a class diagram for a traffic monitoring system. Apply the
Controller pattern to identify the class responsible for coordinating the
traffic data and generating reports. (C02,K4)
Category IV:
Create a class diagram for a library management system. Apply the Expert
pattern to determine which class should be responsible for checking if a
book is available for checkout. (C02,K4)
Category V:
Apply the Controller pattern to a banking system. Identify an alternative
scenario where a different class would be responsible for coordinating the
transfer of funds between accounts. (C02,K4)
11. Part AQ& A(with Klevel andCO)
S.N Questions
K Level CO
o
Level
1 K2 C02
Define patterns.
A pattern is a named problem/solution pair that can be applied in
new context, with advice on how to apply it in novel situations and
2 K2 C02
How to Apply the GRASP Patterns?
The following sections present the first five GRASP patterns:
Information Expert
Creator
High Cohesion
Low Coupling
Controller
3 K2 C02
Define Responsibilities and Methods.
The UML defines a responsibility as “a contract or obligation of a
classifier” [OMG01]. Responsibilities are related to the obligations of
an object in terms of its behavior.
• Doing
4 List out some scenarios that illustrate varying degrees of functional K1 C02
cohesion.
7 K2 C02
What is meant by Abstract Class Abstract Factory?
A common variation on Abstract Factory is to create an abstract class
factory that is accessed using the Singleton pattern, reads from a
system property to decide which of its subclass factories to create,
and then returns the appropriate subclass instance.. Toolkit class,
which is an abstract class abstract factory for creating families of GUI
widgets for different operating system and GUI subsystems.
8 K2 C02
Differentiate coupling and cohesion.
Coupling deals with interactions between objects or software
components while cohesion deals with the interactions within a single
object or software component. Highly cohesive components can lower
coupling because only a minimum of essential information need to b
passed between components.
9 K2 C02
What is meant by Low Coupling?
Coupling is a measure of how strongly one element is connected to,
has knowledge of, or relies on other elements. An element with low
(or weak) coupling is not dependent on too many other elements;
"too many" is context-dependent, but will be examined. These
elements include classes, subsystems, systems, and so on.
10 K2 C02
What is meant by High cohesion?
Cohesion (or more specifically, functional cohesion) is a measure of
how strongly related and focused the responsibilities of an element
are. An element with highly related responsibilities, and which does
not do a tremendous amount of work, has high cohesion. These
elements include classes, subsystems, and so on.
11 K2 C04
What is meant by Pure Fabrication?
This is another GRASP pattern. A Pure Fabrication is an arbitrary
creation of the designer, not a software class whose name is inspired
by the Domain Model. A use-case controller is a kind of Pure
Fabrication.
12 K2 C04
How to create an instance?
Any message can be used to create an instance, but there is a convention
in the UML to use a message named create for this purpose. If anothe
(perhaps less obvious) message name is used, the message may be
annotated with a special feature called a UML stereotype, like so
«create». The create message may include parameters, indicating the
passing of initial values. This indicates, for example, a constructor cal
with parameters in Java.
13
Define Controller. K2 C04
Assign the responsibility for receiving or handling a system event
message to a class representing one of the following choices: -
Represents the overall system, device, or subsystem (facade
controller). - Represents a use case scenario within which the system
event occurs, often named Handler, Coordinator, or Session (use-case
or session controller). - Use the same controller class for all system
events in the same use case scenario.
• Information Expert
• Creator
• High Cohesion
• Low Coupling
• Controller
15 K2 C04
What do you mean by design patterns?
Design patterns are devices that allow systems to share knowledge
about their design, by describing commonly recurring structures of
communicating components that solve a general design problem
within a particular context.
12. Part BQs(with Klevel andCO)
S.No Questions
K Level CO Level
2 NPTEL Swayam
https://onlinecourses.nptel.ac.in/noc16_cs19
http://engineeringvideolectures.com/video/1237
www.uml-diagrams.org/uml-object-oriented-concepts.html
14. Real time Applications in day to
daylife and to Industry
To create a Plan abstract class and concrete classes that extends the Plan
abstract class. A factory class GetPlanFactory is defined as a next step.
GenerateBill class will use GetPlanFactory to get a Plan object. It will pass
information (DOMESTICPLAN / COMMERCIALPLAN /
INSTITUTIONALPLAN) to GetPalnFactory to get the type of object it needs.
Factory Method
15. Contents beyond the Syllabus ( COE related Value
added courses)
10.02.24
1 Internal Assessment to
Test I
16.02.24
01.04.24
2 Internal Assessment
To
Test II
06.04.24
20.04.24
3 Model Examination To
30.04.24
17. Prescribed Text Books & Reference Books
TEXT BOOKS:
REFERENCES:
Disclaimer:
This document is confidential and intended solely for the educational purpose of RMK Group
of Educational Institutions. If you have received this document through email in error, please
notify the system manager. This document contains proprietary information and is intended
only to the respective group / learning community as intended. If you are not the addressee
you should not disseminate, distribute or copy through e-mail. Please notify the sender
immediately by e-mail if you have received this document by mistake and delete this document
from your system. If you are not the intended recipient you are notified that disclosing,
copying, distributing or taking any action in reliance on the contents of this information is
strictly prohibited.