Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
11 ooad uml-14
1. Object-Oriented Analysis and Design Using UML
Objectives
In this session, you will learn to:
– Apply framework and patterns to design the software system
– Generate code from design model
Ver. 1.0 Slide 1 of 24
2. Object-Oriented Analysis and Design Using UML
Understanding Frameworks and Patterns
A development team tends to reuse its existing solutions to
reduce the development time and increase quality.
Reusing an existing solution includes reusing the existing
code, a component, a test case, or a concept that has been
implemented in similar projects.
Frameworks and patterns are standards, which are used to
make the software components reusable.
Ver. 1.0 Slide 2 of 24
3. Object-Oriented Analysis and Design Using UML
Defining Patterns and Frameworks
Frameworks:
Define features that are common to similar applications
belonging to a particular domain.
Increase reusability and reduce application development time.
Microsoft Foundation Classes (MFC) provided with Microsoft
VC++ is an example of a framework that allows you to develop
Graphical User Interfaces (GUI) having common
characteristics, such as command buttons.
Ver. 1.0 Slide 3 of 24
4. Object-Oriented Analysis and Design Using UML
Defining Patterns and Frameworks (Contd.)
The characteristics of a framework are:
Represents a collection of classes or a library that enables you
to perform a particular function without developing the code
from scratch.
Contains abstract and concrete classes that realize interfaces
to conform to predefined specifications.
Contains classes that can be extended by subclassing.
Defines abstract methods that receive messages in the derived
class from the predefined classes.
Ver. 1.0 Slide 4 of 24
5. Object-Oriented Analysis and Design Using UML
Defining Patterns and Frameworks (Contd.)
Pattern:
Is a set of principles and guidelines that provide the standard
solution to a given problem.
Enables you to create solutions that can be reused to fulfill new
requirements without making modifications in the existing
system.
Is useful in making communication better among software
components.
Is useful in making the design reusable, solving a problem in
the most efficient manner, and assigning responsibilities to the
classes.
Are generally categorized into the following categories:
General Responsibility Assignment Software Patterns (GRASP)
Gang of Four (GoF) patterns
Ver. 1.0 Slide 5 of 24
6. Object-Oriented Analysis and Design Using UML
GRASP
GRASP is a set of patterns that provides the principles of
assigning responsibilities to objects, such as creating and
destroying an object.
Consists of the following patterns:
– Expert: Provides guidelines to assign responsibility to a class
that contains the relevant information.
– Creator: Provides guidelines for assigning responsibility to a
new object of a particular class.
– Controller: Provides guidelines for handling system events.
The expert pattern provides guidelines to assign
responsibility to a class that contains the relevant
information.
Ver. 1.0 Slide 6 of 24
7. Object-Oriented Analysis and Design Using UML
GRASP (Contd.)
According to the creator pattern, a class is responsible for
creating objects if any of the following conditions are true:
A class contains another class.
A class records the instances of another class.
A class uses the objects of another class.
A class provides information to initialize the objects of another
class.
According to the controller pattern, you assign the
responsibility of handling the system event to the class that
fulfills one or more of the following criteria:
Represents the overall system
Represents a use case handler
Ver. 1.0 Slide 7 of 24
8. Object-Oriented Analysis and Design Using UML
GoF Patterns
The GoF patterns:
Are based on open-close principle, which suggests that the
design should be open to extension and close to modification.
Have the following features:
– Enables you to reuse existing solutions for common design
problems.
– Establishes common terminology for problems and their solutions
to improve understanding.
Are broadly categorized into three types:
Creational
Structural
Behavioral
Ver. 1.0 Slide 8 of 24
9. Object-Oriented Analysis and Design Using UML
Creational Patterns
Creational patterns provide techniques for creating objects
and managing the life cycle of the objects.
Commonly used creational patterns are:
Factory
Builder
Singleton
Factory Pattern:
Provides a class known as factory class, which controls the
lifetime of the objects of the subclasses of an abstract base
class.
Is required in the following cases:
When you are not able to anticipate which type of objects are
required at runtime.
When the base class is abstract and the pattern must return
an initialized object.
Ver. 1.0 Slide 9 of 24
10. Object-Oriented Analysis and Design Using UML
Creational Patterns (Contd.)
Builder Pattern:
Separates the creation and construction of a complex object
from its representation.
Enables you to create several representations of the same
complex object with a flexibility of modifying the alignment of
the objects.
Is similar to abstract factory method because both create
family of objects.
Assembles or structures the simple objects to represent a
complex object.
Ver. 1.0 Slide 10 of 24
11. Object-Oriented Analysis and Design Using UML
Creational Patterns (Contd.)
Singleton Pattern:
Is a class that allows you to create only one instance of itself.
Is useful when you need to access a single object representing
a real life object, such as a printer or a mouse.
Is defined using a static data member that keeps track of the
life of the created object.
Ver. 1.0 Slide 11 of 24
12. Object-Oriented Analysis and Design Using UML
Structural Patterns
Structural design pattern describes how classes and objects
can be combined to form larger structures using object
composition.
The most commonly used structural patterns are:
Composite
Proxy
Decorator
Facade
Ver. 1.0 Slide 12 of 24
13. Object-Oriented Analysis and Design Using UML
Structural Patterns (Contd.)
Composite Pattern:
Represents a complex object, which can further consists of
simple objects and complex objects.
Provides you with interfaces to access the composite and
simple objects within the composite object.
Is represented as a tree in which the composite objects
represent the nodes and simple objects represent leaves of the
tree.
Ver. 1.0 Slide 13 of 24
14. Object-Oriented Analysis and Design Using UML
Structural Patterns (Contd.)
Proxy pattern:
Is used to represent the complex objects as simple objects.
Allows you to postpone the creation of an object until you
require it.
Decorator pattern:
Allows you to modify the behavior of individual objects without
creating a new derived class.
Is used to define the additional functionality for the existing
objects.
• Facade pattern:
Simplifies the software development by providing simplified
interfaces.
Is also useful in implementing layered architecture.
Ver. 1.0 Slide 14 of 24
15. Object-Oriented Analysis and Design Using UML
Behavioral Patterns
Behavioral patterns provide guidelines for enabling
communication between two objects.
The most commonly used behavioral patterns are:
– Chain of Responsibility: Describes how various classes
should handle a request. Each class contains the logic that
describes the types of requests it can handle. It also describes
how to pass off the requests that the class cannot handle to
another class.
– Command: Describes how a request of method invocation is
transferred only to a specific module.
– Observer: Enables you to create separate objects for
displaying the information in various forms.
Ver. 1.0 Slide 15 of 24
16. Object-Oriented Analysis and Design Using UML
Modeling Design Patterns
Design patterns are modeled with respect to the real world
scenarios and with respect to the developer who creates the
design pattern.
The various views in which you model the design patterns
are:
– Outside view: Represents the structure of the design pattern
as a parameterized collaboration.
– Inside view: Represents the structure of the design pattern as
seen by the creator of the pattern, such as the developer. The
inside view is depicted as a collaboration without parameters.
Ver. 1.0 Slide 16 of 24
17. Object-Oriented Analysis and Design Using UML
Associating Patterns with Tiered Architecture
Design patterns are implemented in tiered applications,
which are developed to support companies in their business
operations.
The following table lists the design patterns and the tiers on
which they are generally implemented.
Pattern Tier
Façade Business Tier
Builder Business Tier
Singleton Business Tier
Composite Presentation Tier
Decorator Presentation Tier
Chain of Responsibility Business Tier
Command Business Tier
Observer Presentation Tier
Ver. 1.0 Slide 17 of 24
18. Object-Oriented Analysis and Design Using UML
Mapping Design to Code
Using CASE tools, such as Rational Rose, Jude, and Visio,
you can automatically generate code from class and
communication diagrams.
CASE tools use various thumb rules and heuristic principles
to generate code from the designed model.
You need to optimize the code generated using CASE tools
according to the operating system.
You can also reverse engineer the code into the design
model to measure the deviation from the designed model
after the code is modified.
Ver. 1.0 Slide 18 of 24
19. Object-Oriented Analysis and Design Using UML
Generating Code from a Design Model
CASE tools, such as Rational Rose and Visio:
Automatically generate code from class and collaboration
diagrams.
Support reverse engineering that enables you to generate
design models from the code that may be modified during the
course of implementation and testing phases of the project.
Support reverse engineering the code into the design model to
measure the deviation from the designed model after the code
is modified.
You focus on the class diagrams and communication
diagrams while generating code because code is generated
from class methods and variables.
Ver. 1.0 Slide 19 of 24
20. Object-Oriented Analysis and Design Using UML
Refactoring Design
Refactoring Design:
Is a technique for restructuring internal structure of the existing
code without changing its external behavior.
Alters the class model without altering the architecture of a
system.
The factors that may lead to refactoring are:
Identification of new methods in the implementation phase due
to the platform on which the design is implemented.
The methods that are derived from the communication diagram
are not present in the class diagram.
Ver. 1.0 Slide 20 of 24
21. Object-Oriented Analysis and Design Using UML
Applying Session Facade
A session facade is a design pattern that is used to create
enterprise applications, such as applications that use
Enterprise Java Beans (EJB).
In an enterprise application, a session facade pattern is
defined as a high-level business component such as a
session bean.
The high-level business component defines the complete
interaction among low-level business components, such as
entity beans.
The session facade pattern acts as an interface to the
low-level business components.
It decouples low-level business components from one
another, making the design of enterprise applications more
reusable and manageable.
Ver. 1.0 Slide 21 of 24
22. Object-Oriented Analysis and Design Using UML
Demo: Generating C# Code for Bank ATM System
• Problem Statement:
Generate the C# code of the Bank ATM model using the Visio.
Ver. 1.0 Slide 22 of 24
23. Object-Oriented Analysis and Design Using UML
Summary
In this session, you learned that:
A framework is a unit of architecture that provides a reusable
and extensible solution to a group of problems.
A pattern is a named problem-solution pair that enables you to
apply standard solution to reoccurring problems in the design
and implementation phases of SDLC.
GRASP represents a set of patterns that are used to assign
responsibilities to different identified classes.
A design pattern provides standard approach for performing
tasks so that the solution becomes reusable and maintainable.
The three types of GoF are:
Structural
Creational
Behavioral
Ver. 1.0 Slide 23 of 24
24. Object-Oriented Analysis and Design Using UML
Summary (Contd.)
Creational patterns deal with the creation and lifetime of
objects of other classes.
Structural patters deal with the structure of the system.
Behavioral patterns deal with the behavior of the system.
Code generation is the process of deriving code from the
design model.
Refactoring design is a technique for restructuring internal
structure of the existing code without changing its external
behavior.
Ver. 1.0 Slide 24 of 24
Notas do Editor
Initiate the session by explaining the session objectives. Tell the students that the success of a software solution depends largely on how well its various components have been designed. An effort should be made to ensure that the components of the existing software solution can be reused. This can be done by using frameworks and patterns. You need to elaborate the concept of applying patterns and frameworks by using the case study of BlueSeas Inc. This will help students to relate their programming skills with the actual practices followed in the software industry.
Explain what frameworks and features are and how they help in making software components reusable. Explain the concept of frameworks by using the example of Microsoft Foundation Classes (MFC).
Explain what frameworks and features are and how they help in making software components reusable. Explain the concept of frameworks by using the example of Microsoft Foundation Classes (MFC).
Explain the characteristics of a framework.
Define patterns and their advantages. Also enumerate the two types of patterns.
Explain the concept behind GRASP patterns. Explain the types of patterns included in GRASP. Explain how the expert pattern assigns responsibilities to classes.
Explain how the creator pattern assigns responsibilities to classes. Next, explain how the controller pattern assigns responsibilities to classes.
Explain the concept and features of GoF patterns. Also enumerate the three types of GoF patterns.
Explain the concept of creational patterns. Enumerate the three types of creational design patterns. Explain in detail the factory pattern by using the Shape example given in the student guide.
Explain in detail the buider pattern by using the example of the RAS application given in the student guide.
Explain in detail the singleton pattern by using the example given in the student guide.
Explain the concept of structural design patterns and enumerate the commonly used structural patterns.
Explain in detail the composite pattern by using the example of the RAS application given in the student guide.
Explain in detail the proxy, decorator, and facade patterns by using the example of the RAS application given in the student guide.
Explain the concept of behavioral patterns and enumerate the commonly used behavioral patterns.
Explain the various views for modeling design patterns. Explain the concept of modeling design patterns by using the example given in the student guide.
Explain the design patterns associated with the three types of tiers.
Use the examples given in the student guide to explain how the design maps to the code.
Use the examples given in the student guide to explain how the design maps to the code.
Explain the concept of refactoring design. Also explain the factors that may lead to refactoring by using the example given in the student guide.
Explain the concept of session façade by using the example given in the student guide.
Summarize the session by using the summary points given on the slide.
Summarize the session by using the summary points given on the slide.