0% found this document useful (0 votes)
26 views116 pages

Chapter 3 Design Patterns - Mero Template Ma

Chapter 3 discusses design patterns in software development, highlighting their importance as reusable solutions to common problems faced by developers. It classifies design patterns into three categories: Creational, Structural, and Behavioral, and provides examples of each. The chapter emphasizes the benefits of using design patterns, such as promoting best practices, reusability, and reducing code complexity.

Uploaded by

anojpaudel60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views116 pages

Chapter 3 Design Patterns - Mero Template Ma

Chapter 3 discusses design patterns in software development, highlighting their importance as reusable solutions to common problems faced by developers. It classifies design patterns into three categories: Creational, Structural, and Behavioral, and provides examples of each. The chapter emphasizes the benefits of using design patterns, such as promoting best practices, reusability, and reducing code complexity.

Uploaded by

anojpaudel60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 116

Chapter 3

Design Pattern
Er. Shiva Ram Dam
Assistant Professor, Pokhara University
Contents:
1. Introduction to Design Patterns
2. Programming Paradigm Vs Design Patterns
3. Importance of Design patterns
4. Classification of Design patterns
5. Software Architecture

7/13/2022 Design Pattern, OOSD, BSE VI 2


3.1 Design Patterns
• In 1994, four authors Erich Gamma, Richard Helm, Ralph
Johnson and John Vlissides published a book titled Design
Patterns - Elements of Reusable Object-Oriented
Software which initiated the concept of Design Pattern in
Software development.
• In software engineering, a software design pattern is a
general, reusable solution of how to solve a common
problem when designing an application or system.
• Unlike a library or framework, which can be inserted and
used right away, a design pattern is more of a template to
approach the problem at hand.

7/13/2022 Design Pattern, OOSD, BSE VI 3


• Design patterns represent the best practices used
by experienced object-oriented software
developers.
• Design patterns are solutions to general
problems that software developers faced during
software development.
• These solutions were obtained by trial and error
by numerous software developers over quite a
substantial period of time.

7/13/2022 Design Pattern, OOSD, BSE VI 4


• Design patterns are typical solutions to commonly
occurring problems in software design.
• They are like pre-made blueprints that you can customize
to solve a recurring design problem in your code.
• We can’t just find a pattern and copy it into your program,
the way you can with off-the-shelf functions or libraries.
• The pattern is not a specific piece of code, but a general
concept for solving a particular problem.
• We can follow the pattern details and implement a
solution that suits the realities of our own program.

7/13/2022 Design Pattern, OOSD, BSE VI 5


• Patterns are often confused with algorithms, because both
concepts describe typical solutions to some known problems.
• While an algorithm always defines a clear set of actions that can
achieve some goal, a pattern is a more high-level description of a
solution.
• The code of the same pattern applied to two different programs
may be different.
• An analogy to an algorithm is a cooking recipe: both have clear
steps to achieve a goal. On the other hand, a pattern is more like a
blueprint: we can see what the result and its features are, but the
exact order of implementation is up to us.

7/13/2022 Design Pattern, OOSD, BSE VI 6


Contents of Pattern:
• Intent of the pattern briefly describes both the
problem and the solution.
• Motivation further explains the problem and the
solution the pattern makes possible.
• Structure of classes shows each part of the
pattern and how they are related.
• Code example in one of the popular
programming languages makes it easier to grasp
the idea behind the pattern.
7/13/2022 Design Pattern, OOSD, BSE VI 7
Programming paradigm Vs Design patterns.
Programming paradigm is a method, a way, a principle of
programming.
• It describes the programming process, which is the way, programs
are made.
• It explains core structure of program written in certain paradigm,
everything that program consists of and its components.
• Some of programming paradigms: Procedural paradigm, Functional
paradigm, Object-oriented paradigm, Modular programming, and
Structured paradigm, Aspect-oriented Programming, Subject-
oriented programming, Event-driven programming, etc...

7/13/2022 Design Pattern, OOSD, BSE VI 8


• According to GoF definition of design patterns:
• “In software engineering, a software design pattern is a
general reusable solution to a commonly occurring problem
within a given context in software design. Design patterns
are formalized best practices that the programmer can use
to solve common problems when designing an application
or system.”
• Design patterns are formalized solutions to common
programming problems.
• They mostly refer to object-oriented programming, but
some of solutions can be applied in various paradigms.

7/13/2022 Design Pattern, OOSD, BSE VI 9


Importance of Design pattern
Design patterns offer a best practice approach to support object-oriented software design, which is easier to
design, implement, change, test and reuse. These design patterns provide best practices and structures.
1. Proven Solution
Design patterns provide a proven, reliable solution to a common problem, meaning the software
developer does not have to “reinvent the wheel” when that problem occurs.
2. Reusable
Design patterns can be modified to solve many kinds of problems – they are not just tied to a
single problem.
3. Expressive
Design patterns are an elegant solution.
4. Prevent the Need for Refactoring Code
Since the design pattern is already the optimal solution for the problem, this can avoid refactoring.
5. Lower the Size of the Codebase
Each pattern helps software developers change how the system works without a full redesign.
Further, as the “optimal” solution, the design pattern often requires less code.

7/13/2022 Design Pattern, OOSD, BSE VI 10


3.4 Classification of Design Patterns,

7/13/2022 Design Pattern, OOSD, BSE VI 11


• As per the design pattern reference book Design Patterns -
Elements of Reusable Object-Oriented Software, there are 23
design patterns which can be classified in three categories:
– Creational,
– Structural and
– Behavioral patterns.

7/13/2022 Design Pattern, OOSD, BSE VI 12


1. Creational Patterns
• These design patterns deal with the object creation and initialization.
• They provide a way to create objects while hiding the creation logic, rather
than instantiating objects directly using new operator.
• This pattern gives program more flexibility in deciding which objects need to
be created for a given case.
• These design patterns are used to increase flexibility and to reuse existing
code.
• Design patterns of such categories are:
– Singleton
– Factory Method
– Abstract Factory
– Builder
– Prototype

7/13/2022 Design Pattern, OOSD, BSE VI 13


2. Structural Patterns:
• These design patterns deal with class and object composition. Concept of
inheritance is used to compose interfaces and define ways to compose objects to
obtain new functionalities.
• A structural design pattern deals with how to assemble objects and classes into
larger structures.
• Design patterns of such categories are:
– Adapter
– Bridge
– Composite
– Decorator
– Facade
– Flyweight
– Proxy

7/13/2022 Design Pattern, OOSD, BSE VI 14


3. Behavioral Patterns
• These design patterns deal with communication between classes and objects.
• These are concerned with how responsibilities are assigned between objects.
• Design patterns of such categories are:
– Chain of Responsibility
– Command
– Interpreter
– Iterator
– Mediator
– Memento
– Observer
– State
– Strategy
– Visitor
– Template Method

7/13/2022 Design Pattern, OOSD, BSE VI 15


A. Creational Patterns
1. Singleton
2. Factory
3. Abstract Factory
4. Builder
5. Prototype

7/13/2022 Design Pattern, OOSD, BSE VI 16


1. Singleton Pattern
• Singleton pattern is one of the simplest design patterns in Java.
• This type of design pattern comes under creational pattern as this
pattern provides one of the best ways to create an object.
• This pattern involves a single class which is responsible to create an
object while making sure that only single object gets created.
• This class provides a way of access its only object which can be
accessed directly without instantiating the object of the class.
• The implementation involves a static member in the "Singleton"
class, a private constructor and a static public method that returns a
reference to the static member.

7/13/2022 Design Pattern, OOSD, BSE VI 17


• To create a singleton class, a class must implement
the following properties:
– Create a private constructor of the class to restrict object
creation outside of the class.
– Create a private attribute of the class type that refers to
the single object.
– Create a public static method that allows us to create and
access the object we created. Inside the method, we will
create a condition that restricts us from creating more
than one object.

7/13/2022 Design Pattern, OOSD, BSE VI 18


7/13/2022 Design Pattern, OOSD, BSE VI 19
Here any other objects cannot
be created under the Singleton
Class.

7/13/2022 Design Pattern, OOSD, BSE VI 20


2. Factory Pattern
• This pattern is also known as Virtual Constructor. Factory pattern is one of
the most used design patterns.
• This type of design pattern comes under creational pattern as this pattern
provides one of the best ways to create an object.
• In factory pattern, we create objects without exposing the creation logic to
the client and refer to newly created object using a common interface.
• Here, we define an interface or abstract class for creating an object but let
the subclasses decide which class to instantiate.
• In other words, subclasses are responsible to create the instance of the
class.
• An interface in Java is a blueprint of a class. It has static constants and
abstract methods.
• The interface in Java is a mechanism to achieve abstraction.

7/13/2022 Design Pattern, OOSD, BSE VI 21


• Here in the UML diagram, we
create a Shape interface and
concrete classes (Circle, Square
and Rectangle) implementing
the Shape interface.
• A factory class ShapeFactory is
defined as a next step.
• FactoryPatternDemo, our demo
class will use ShapeFactory to
get a Shape object.
• It will pass information (CIRCLE
/ RECTANGLE / SQUARE)
to ShapeFactory to get the type
of object it needs.

7/13/2022 Design Pattern, OOSD, BSE VI 22


7/13/2022 Design Pattern, OOSD, BSE VI 23
• Advantage of Factory Design Pattern
– Factory Method Pattern allows the sub-classes to
choose the type of objects to create.
– It promotes the loose-coupling by eliminating the
need to bind application-specific classes into the code.
That means the code interacts solely with the
resultant interface or abstract class, so that it will
work with any classes that implement that interface
or that extends that abstract class.

7/13/2022 Design Pattern, OOSD, BSE VI 24


3. Abstract Factory Pattern
• An abstract Factory Pattern is also known as Kit.
• Abstract Factory patterns work around a super-factory which
creates other factories.
• This factory is also called as factory of factories.
• This type of design pattern comes under creational pattern as this
pattern provides one of the best ways to create an object.
• In Abstract Factory pattern an interface is responsible for creating a
factory of related objects without explicitly specifying their classes.
• Each generated factory can give the objects as per the Factory
pattern.
7/13/2022 Design Pattern, OOSD, BSE VI 25
• Here in the UML diagram, we
create a Shape interface and a
concrete class implementing it.
• We create an abstract factory
class AbstractFactory as next step.
• Factory class ShapeFactory is
defined, which extends
AbstractFactory.
• A factory creator/generator class
FactoryProducer is created.
• AbstractFactoryPatternDemo, our
demo class uses FactoryProducer
to get a AbstractFactory object.
• It will pass information (CIRCLE /
RECTANGLE / SQUARE for Shape)
to AbstractFactory to get the type
of object it needs.

7/13/2022 Design Pattern, OOSD, BSE VI 26


7/13/2022 Design Pattern, OOSD, BSE VI 27
4. Builder Pattern
• Builder pattern builds a complex object using simple objects and
using a step by step approach.
• This type of design pattern comes under creational pattern as this
pattern provides one of the best ways to create an object.
• A Builder class builds the final object step by step.
• This builder is independent of other objects.
– Consider the construction of a home.
– Home is the final end product (object) that is to be returned as the
output of the construction process.
– It will have many steps like basement construction, wall construction,
and so on roof construction.
– Finally, the whole home object is returned.

7/13/2022 Design Pattern, OOSD, BSE VI 28


• Let us consider a business case of fast-food restaurant.
– Here, a typical meal could be a burger and a cold drink.
– Burger could be either a Veg Burger or Chicken Burger and will be
packed by a wrapper.
– Cold drink could be either a Coke or Pepsi and will be packed in a
bottle.

7/13/2022 Design Pattern, OOSD, BSE VI 29


• We are going to create an Item interface representing food items
such as burgers and cold drinks and
• concrete classes implementing the Item interface and
• a Packing interface representing packaging of food items and
concrete classes
• implementing the Packing interface as burger would be packed in
wrapper
• and cold drink would be packed as bottle.
• We then create a Meal class having ArrayList of Item and
• a MealBuilder to build different types of Meal objects by
combining Item. BuilderPatternDemo,
• our demo class will use MealBuilder to build a Meal.

7/13/2022 Design Pattern, OOSD, BSE VI 30


• We are going to create an Item interface
representing food items such as burgers
and cold drinks and
• concrete classes implementing
the Item interface and
• a Packing interface representing
packaging of food items and concrete
classes
• implementing the Packing interface as
burger would be packed in wrapper
• and cold drink would be packed as
bottle.
• We then create a Meal class
having ArrayList of Item and
• a MealBuilder to build different types
of Meal objects by
combining Item. BuilderPatternDemo,
• our demo class will use MealBuilder to
build a Meal.

7/13/2022 Design Pattern, OOSD, BSE VI 31


5. Prototype Design Pattern
• Prototype pattern refers to creating duplicate object while keeping
performance in mind.
• Prototype allows us to hide the complexity of making new instances from
the client.
• The concept is to copy an existing object rather than creating a new
instance from scratch, something that may include costly operations.
• The existing object acts as a prototype and contains the state of the
object.
• The newly copied object may change same properties only if required.
• This approach saves costly resources and time, especially when object
creation is a heavy process.
• One of the best available ways to create an object from existing objects is
the clone() method.

7/13/2022 Design Pattern, OOSD, BSE VI 32


• We're going to create an
abstract class Shape and
concrete classes Circle,
Rectangle, Square
extending the Shape class.
• A class ShapeCache is
defined as a next step
which stores shape objects
in a Hashtable and returns
their clone when
requested.
• PrototypePatternDemo,
our demo class will
use ShapeCache class to
get a Shape object.

7/13/2022 Design Pattern, OOSD, BSE VI 33


6. Adapter Pattern
• The adapter design pattern is one of the structural
design patterns and it’s used so that two unrelated
interfaces can work together.
• The object that joins these unrelated interfaces is
called an Adapter.
• As a real-life example,
– we can think of a mobile charger as an adapter because
the mobile battery needs 3 volts to charge but the normal
socket produces either 120V (US) or 240V (Nepal).
– So, the mobile charger works as an adapter between the
mobile charging socket and the wall socket.
7/13/2022 Design Pattern, OOSD, BSE VI 34
• We have
a MediaPlayer interface and
a concrete
class AudioPlayer implementi
ng
the MediaPlayer interface.
• AudioPlayer can play mp3
format audio files by default.
• We are having another
interface AdvancedMediaPla
yer and concrete classes
implementing
the AdvancedMediaPlayer int
erface.
• These classes can play vlc
and mp4 format files.

7/13/2022 Design Pattern, OOSD, BSE VI 35


• We want to make AudioPlayer to
play other formats as well.
• To attain this, we have created an
adapter
class MediaAdapter which
implements
the MediaPlayer interface and
uses AdvancedMediaPlayer object
s to play the required format.
• AudioPlayer uses the adapter
class MediaAdapter passing it the
desired audio type without
knowing the actual class which
can play the desired
format. AdapterPatternDemo, our
demo class will
use AudioPlayer class to play
various formats.

7/13/2022 Design Pattern, OOSD, BSE VI 36


B. Structural Patterns
6. Adapter
7. Bridge
8. Composite
9. Decorator
10.Façade
11.Flyweight
12.Proxy
7/13/2022 Design Pattern, OOSD, BSE VI 37
7. Bridge Design Pattern
• The Bridge design pattern allows us to separate the abstraction from the
implementation.
• It is a structural design pattern.
• There are 2 parts in Bridge design pattern : Abstraction and
Implementation.
• Bridge is used when we need to decouple an abstraction from its
implementation so that the two can vary independently.
• This type of design pattern comes under structural pattern as this pattern
decouples implementation class and abstract class by providing a bridge
structure between them.
• This pattern involves an interface which acts as a bridge which makes the
functionality of concrete classes independent from interface implementer
classes. Both types of classes can be altered structurally without affecting
each other.

7/13/2022 Design Pattern, OOSD, BSE VI 38


• We are
demonstrating use of
Bridge pattern via
following example in
which a circle can be
drawn in different
colors using same
abstract class method
but different bridge
implementer classes.
7/13/2022 Design Pattern, OOSD, BSE VI 39
• We have
a DrawAPI interface which
is acting as a bridge
implementer and
• concrete classes RedCircle,
GreenCircle implementing
the DrawAPI interface.
• Shape is an abstract class
and will use object
of DrawAPI.
• BridgePatternDemo, our
demo class will
use Shape class to draw
different colored circle.

7/13/2022 Design Pattern, OOSD, BSE VI 40


8. Composite Design Pattern
• Composite pattern is a partitioning design pattern and describes a
group of objects that is treated the same way as a single instance of
the same type of object.
• The intent of a composite is to “compose” objects into tree
structures to represent part-whole hierarchies.
• It allows us to have a tree structure and ask each node in the tree
structure to perform a task.
• In an organization, it has general managers and under general
managers, there can be managers and under managers there can
be developers. Now you can set a tree structure and ask each node
to perform common operation like getSalary().

7/13/2022 Design Pattern, OOSD, BSE VI 41


• Client uses the component
class interface to interact
with objects in the
composition structure.
• If recipient is the leaf then
request will be handled
directly.
• If recipient is a composite,
then it usually forwards
the request to its child for
performing the additional
operations.

7/13/2022 Design Pattern, OOSD, BSE VI 42


9. Decorator
• Decorator pattern allows a user to add new functionality to
an existing object without altering its structure.
• This type of design pattern comes under structural pattern
as this pattern acts as a wrapper to existing class.
• This pattern creates a decorator class which wraps the
original class and provides additional functionality keeping
class methods signature intact.
• We are demonstrating the use of decorator pattern via
following example in which we will decorate a shape with
some color without alter shape class.

7/13/2022 Design Pattern, OOSD, BSE VI 43


• In the UML diagram,
• we create a Shape interface and
concrete classes implementing
the Shape interface.
• We will then create an abstract
decorator
class ShapeDecorator implemen
ting the Shape interface and
having Shape object as its
instance variable.
• RedShapeDecorator is concrete
class
implementing ShapeDecorator.
• DecoratorPatternDemo, our
demo class will
use RedShapeDecorator to
decorate Shape objects.

7/13/2022 Design Pattern, OOSD, BSE VI 44


10. Façade Design Pattern
• As the name suggests, it means the face of the building. The
people walking past the road can only see this glass face of
the building.
• They do not know anything about it, the wiring, the pipes and
other complexities.
• It hides all the complexities of the building and displays a
friendly face.

7/13/2022 Design Pattern, OOSD, BSE VI 45


10. Façade Design Pattern
• You, as client want access to different menus of different
restaurants.
• You do not know what are the different menus they have. You
just have access to hotel keeper who knows his hotel well.
• Whichever menu you want, you tell the hotel keeper and he
takes it out of from the respective restaurants and hands it
over to you.
• Here, the hotel keeper acts as the facade, as he hides the
complexities of the system hotel.

7/13/2022 Design Pattern, OOSD, BSE VI 46


• We are going to create
a Shape interface and
concrete classes
implementing
the Shape interface.
• A facade
class ShapeMaker is
defined as a next step.
• ShapeMaker class uses
the concrete classes to
delegate user calls to
these classes.
• FacadePatternDemo,
our demo class, will
use ShapeMaker class to
show the results.

7/13/2022 Design Pattern, OOSD, BSE VI 47


11. Flyweight Design Pattern
• Flyweight is a pattern
– dedicated to building light objects by abstracting parts
– that can be reused and shared
– in order to create new objects when required,
– and reusing objects created by other instances,
– significantly reducing the amount of memory being used by the
application.
• This pattern is useful when resource optimization is
fundamental,
– because it eliminates redundancy on objects with identical
properties.

7/13/2022 Design Pattern, OOSD, BSE VI 48


The components included in the pattern are:
• Client:
– Object which triggers the execution.
– The client requests the Factory for the creation of a
Flyweightobject.
• FlyweightFactory:
– Factory for building the Flyweight objects.
– Before creating the object, the Factory checks if there's
an identical object to the one being requested,
– if so, it returns the existing object;
– if not, it will create the new object and store it in a
cache for further use.
• Flyweight:
– It refers to the objects we want to reuse in order to
create lighter objects.
– The Flyweight object is created or borrowed from the
cache and returned to the client.

7/13/2022 Design Pattern, OOSD, BSE VI 49


Real-world Example:
• By implementing the
Flyweight design pattern,
we are going create an
application for managing
playlists.
• Some songs must be
shared between various
playlists, and
• some songs must have
shared sections between
them in order to save
memory space.
7/13/2022 Design Pattern, OOSD, BSE VI 50
12. Proxy Design pattern
• Proxy means ‘in place of’, ‘representing’ or ‘in place of’ or ‘on
behalf of’ are literal meanings of proxy and that directly
explains Proxy Design Pattern.
• Proxies are also called surrogates, handles, and wrappers.
• This pattern is devoted to the mediation between two objects.
• What we refer as mediation is the series of actions executed before
and after carrying out the task requested by the user.
• The main trait of the Proxy pattern is that
– it keeps the user unaware of the mediation that is being carried out in
the background,
– because the client receives an object structured as expected, all by
interacting, unknowingly, with a proxy

7/13/2022 Design Pattern, OOSD, BSE VI 51


The components included in the
pattern are:
• IObject: It represents the
common interface between the
Object and the Proxy.
• Object: It represents the actual
object the client wants access
to.
• Proxy: Class which implements
IObject and is the virtual
representation of the Object.

7/13/2022 Design Pattern, OOSD, BSE VI 52


1. The client sends a request for
an object to the Factory .
2. The Factory creates a Proxy
for encapsulating the Object.
3. The client executes the Proxy
which was created by the
Factory.
4. The Proxy performs one or
more actions before the
execution of the Object.
5. The Proxy hands over the
execution to the Object.
6. The Proxy performs one or
more actions after the
execution of the Object.
7. The Proxy returns the result

7/13/2022 Design Pattern, OOSD, BSE VI 53


Real-world example
• By implementing the Proxy design
pattern,
– we are going to create a security
mechanism that intercepts processes
executions
– to check if the user attempting to trigger
them has the required privileges, in order to
restrict unauthorized executions.
• Furthermore, each executed process
will be audited and registered.
• All of this will happen without the user
noticing, because the proxy would
encapsulate the security logic

7/13/2022 Design Pattern, OOSD, BSE VI 54


C. Behavioral Patterns
13. Chain of responsibility
14. Command
15. Interpreter
16. Iterator
17. Mediator
18. Memento
19. Observer
20. State
21. Strategy
22. Visitor
23. Template

7/13/2022 Design Pattern, OOSD, BSE VI 55


13. Chain of Responsibility
• The Chain of Responsibility pattern stands out
from others because of its versatility, allowing us
to solve problems where we’re not sure which
object should process a specific request;
• this design pattern can easily solve problems that
inheritance can’t because of its chain structure,
• where a series of objects try to process a request
in sequence.

7/13/2022 Design Pattern, OOSD, BSE VI 56


• Client: User or system triggering
the execution of the pattern.
• AbstractHandler: Base class used
for defining the structure of
every ConcreteHandler. This
class is an aggregation of itself,
which allows it to contain
another AbstractHandler for
carrying on with the execution
chain.
• ConcreteHandler: It represents
the concrete implementation of
an AbstractHandler.

7/13/2022 Design Pattern, OOSD, BSE VI 57


• The client sends a request to the chain of
responsibility for its processing.
• The first Handler tries to process the request but
it’s unable to do it, therefore, it relays the request
to the next handler .
• The second Handler tries to process the request
but it’s unable to do it, therefore, it relays the
request to the next Handler .
• The third Handler tries to process the request but
it’s unable to do it, therefore, it relays the request
to the next Handler .
• The HandlerN (Any handler in the chain) is the one
finally succeeding in processing the request, after
which it sends a response (optional) so it can be
relayed by all the previous Handlers until it reaches
to the Client.

7/13/2022 Design Pattern, OOSD, BSE VI 58


• Real-world example
• By implementing the Chain of Responsibility design
pattern, we are going to implement an order validation
system.
• When we work with ERP or CRM systems, it's fairly
common to manage almost everything through orders,
being sales, purchases, services and installations.
• These orders are highly complex objects compounded by
a lot of other objects, such as customers, providers,
products, etc.
• These systems must check the completion of an order,
and that all of the information they carry is valid to the
type of order being processed.
• To that end, we will use the Chain of Responsibility
pattern and create an effective mechanism for validating
any type of order, by reusing validators between these
different types

7/13/2022 Design Pattern, OOSD, BSE VI 59


14. Command
• The Command design pattern allows us to execute
operations without having to know how they are
implemented.
• These operations are known as commands, and each
operation is implemented as an independent class
performing a very specific action, which may or may
not receive parameters in order to carry out its task.
• One of the advantages offered by this pattern is the
ability to create as many commands as we need and
encapsulate them into an execution interface.

7/13/2022 Design Pattern, OOSD, BSE VI 60


• ICommand: Interface describing the
structure of the commands, which
defines the generic execution method for
all of them.
• Concrete Command: They represent the
concrete commands inheriting from
ICommand. Each of these classes
represents a command that can be
executed independently.
• Command Manager: This component
lets us manage all the commands
available at runtime, from here we're
able to request commands or create new
ones.
• Invoker: It represents the action
triggering one of the commands.

7/13/2022 Design Pattern, OOSD, BSE VI 61


1. The invoker gets a
command from
CommandManager.
2. The invoker executes
the command.
3. The invoker gets
another command
from
CommandManager.
4. The invoker executes
the command.

7/13/2022 Design Pattern, OOSD, BSE VI 62


Real-world example
• By implementing the
Command design
pattern, we are going to
learn how to create our
own, entirely
functional, console by
developing a series of
commands that will be
available for its use
during the execution of
the application.
7/13/2022 Design Pattern, OOSD, BSE VI 63
15. Interpreter
• The Interpreter design pattern is used for evaluating a
determined language and return an Expression.
• This pattern can interpret languages such as Java, C#, SQL,
or even a new one invented by us, and provide a response
based on its evaluation.
• This is one of the most complex design patterns, because
we need to combine various object-oriented programming
techniques in order to implement it, which can make it a bit
difficult to understand.
• The main techniques we're going to be dealing with are
Inheritance, Polymorphism and Recursivity.

7/13/2022 Design Pattern, OOSD, BSE VI 64


• The components included in the Interpreter
pattern are as follows:
• Client: Actor triggering the execution of the
interpreter.
• Context: Object carrying global information to
be used by the interpreter in order to read and
store information of all the classes in the
pattern. This object is sent to the interpreter
which then relays it to the rest of the structure.
• AbstractExpression: Interface for defining the
basic structure of an expression.
• TerminalExpression: It refers to expressions
which, after being evaluated or interpreted, end
the execution of a branch or subtree.
• NonTerminalExpression: These are composite
expressions, which contain more expressions
subject to evaluation. They are interpreted by
using recursivity until a terminal expression is
found.

7/13/2022 Design Pattern, OOSD, BSE VI 65


1. The client creates the context for the
execution of the interpreter.
2. The client creates or gets the expression
to be evaluated.
3. The client requests for the evaluation of
the expression to the interpreter. To that
end, it sends it the context.
4. The Expression calls the Non-terminal
Expressions.
5. The Non-terminal Expressions call all the
Terminal Expressions.
6. The Root Expression requests for the
interpretation of a Terminal Expression.
7. The Expression is completely evaluated
and provides the result of the
interpretation of all the Terminal
Expressions and Non-terminal
Expressions.

7/13/2022 Design Pattern, OOSD, BSE VI 66


Real-world example
• By implementing the Interpreter
design pattern, we are going to build
an application capable of
interpreting SQL commands to send
queries to an Excel file, as if it were a
relational database, where each
sheet would be seen as a chart, and
the columns of that sheet would be
seen as the columns of a chart.
• To that end, we will build our own
class structure for representing the
SQL language, in order to be then
interpreted and provide a result.

7/13/2022 Design Pattern, OOSD, BSE VI 67


16. Iterator
• This design pattern allows us to go over a data structure without
needing to know its internal construction.
• It is especially useful when we are working with complex data
structures, because it lets us go over their elements through an
iterator.
• The iterator is an interface including the necessary methods for
reviewing all the elements of a data structure.
• The most common methods are:
– hasNext: This method returns a Boolean indicating if there are more
elements to be reviewed in the structure.
It returns true if there still are elements left and false if there are
none left.
– next: It returns the next element in the data structure.
7/13/2022 Design Pattern, OOSD, BSE VI 68
• Client: Actor using the iterator.
• Aggregate: Interface defining the
class structures that can be
iterated.
• ConcreteAggregate: Class
containing the data structure we
want to iterate.
• IIterator: Interface defining the
iterator's structure, including the
necessary methods for performing
the iteration over
ConcreteAggregator.
• ConcreteIterator: It represents an
iterator's concrete implementation,
which will be in charge of iterating
the ConcreteAggregate data.

7/13/2022 Design Pattern, OOSD, BSE VI 69


1. The client sends a request for an
iterator to ConcreteAggregate .
2. ConcreteAggregate creates a new
Iterator.
3. The cliententers in a loop in order
to review all the elements on the
structure, the loop ends when there
are no elements left for reviewing,
which is going to be signaled by the
hasNext method.
4. The client sends the request for a
new element to the iterator using
the nextmethod.
5. If there are elements left to be
reviewed, then we return to step 3,
something that is going to be
repeated until all elements have
been reviewed

7/13/2022 Design Pattern, OOSD, BSE VI 70


Real-world example
• By implementing the Iterator design
pattern, we are going to create an
application that allows us to traverse
a hierarchical organizational
structure, by including an iterator,
which will go over the entire tree
sequentially.

7/13/2022 Design Pattern, OOSD, BSE VI 71


17. Mediator
• The Mediator design pattern handles the manner in which a group
of classes interact with each other.
• This pattern is especially useful when we have a large number of
classes communicating directly with one another.
• By implementing this pattern, we can create a bidirectional
communication layer, which can be used by a class in order to
interact with others through a common object acting as a mediator.
• One of the main problems we face when building large projects is
that the number of classes can grow even larger and increase the
interactions and relationships between them.
• This can bring issues with coupling, especially when we're creating
direct communication channels which can be hard to track and
debug.
7/13/2022 Design Pattern, OOSD, BSE VI 72
• Client: Component for starting
the communication with the rest
of the components through the
mediator.
• Components: These are parts of
the mediator communication
network, that is, diverse objects
sharing the same mediator for
communicating with each other.
• Mediador: Component for
handling the communication
between the rest of the
components. It directs the
incoming messages to the
corresponding receiver

7/13/2022 Design Pattern, OOSD, BSE VI 73


1. ComponentA wants to communicate
with ComponentB and sends a message
through the mediator.
2. The mediator may analyze the message
for debugging or tracking purposes, or
for directing it to the receiver.
3. The message is delivered to the
receiver, which in turn sends a response
to the mediator.
4. The mediator receives the response and
directs it to ComponentA.
5. Likewise, the process can go in reverse,
from ComponentB to ComponentA by
repeating the previous steps in order to
achieve a bidirectional communication.

7/13/2022 Design Pattern, OOSD, BSE VI 74


Real-world example
• By implementing the
Mediator design pattern,
we are going to develop a
modular application, which
will have a Mediator as a
central communication
point for all the modules,
eliminating the possibility
to have a dependent
relationship between them.
7/13/2022 Design Pattern, OOSD, BSE VI 75
18. Memento
• This design pattern allows us to record the
state of an object on a specific moment in
order to return it to that state at any given
time.
• Memento is useful when we have many
objects changing over time and, for some
reason, we need to restore them to a previous
state.
7/13/2022 Design Pattern, OOSD, BSE VI 76
• Client: This component affects
the Originator and records a new
state into the Caretaker. In other
words, it's the one making
changes to the object and
recording its state.
• Originator: It is the component
whose state is changing.
• Memento: It is the component
storing the Originator's state on a
specific moment.
• Caretaker: This is the component
registering all the changes
happening in the Originator. It
allows us to travel to any
previous state of the Originator.

7/13/2022 Design Pattern, OOSD, BSE VI 77


1. The Originator creates a new
Memento which represents
its current state.
2. The Client stores the
Memento into the Caretaker
in order to change between
different Originatorstates.
3. After some time, the Client
sends a request to the
Caretaker for a previous state
of the Originator.
4. The Client uses the Memento
sent by the Caretaker to
restore the state of the
Originator.

7/13/2022 Design Pattern, OOSD, BSE VI 78


Real-world example
• By implementing the Memento
design pattern, we are going to
develop a simple but effective
application for receiving
information about an employee.
• Once the information is stored, the
application will allow us to go back
or forward between different
versions of this information that
were stored by the Memento
pattern, as if we were using an
undo (Ctrl + Z) and redo features
(Ctrl + Y).

7/13/2022 Design Pattern, OOSD, BSE VI 79


19. Observer
• This design pattern allows us to observe the
changes suffered by an object, that is, if the
observed object suffers any change, a notification
will be sent to the observers; this is known as
publish-subscribe.
• Observer is one of the main design patterns used
in the development of graphical user interfaces
(GUI), because it allows us to decouple the
graphical component from the action to be
performed.
7/13/2022 Design Pattern, OOSD, BSE VI 80
• IObservable: Interface which must be
implemented by all objects subject to
observation, in it, all the basic
implementable methods are defined.
• ConcreteObservable: This is the
observable class; it implements
IObservable along with its methods.
• IObserver: Interface which must be
implemented by all objects in charge
of observing the changes on
IObservable.
• ConcreteObserver: Concrete class in
charge of watching the changes on
IObservable, it inherits from IObserver
and must implement its methods.

7/13/2022 Design Pattern, OOSD, BSE VI 81


1. ObserverA registers into
the Observable object in
order to be notified of
any changes.
2. ObserverB registers into
the Observable object in
order to be notified of
any changes.
3. The status of the
Observablechanges.
4. All the Observers are
notified that a change
has occurred.
7/13/2022 Design Pattern, OOSD, BSE VI 82
Real-world example
• By implementing the Observer design
pattern, we are going to develop an
application that loads the system
configuration at the start.
• This configuration will automatically
notify all the observer objects of any
changes that would happen in order
to let the user know about them. The
purpose of this approach is to keep
the objects from having to constantly
check for changes.

7/13/2022 Design Pattern, OOSD, BSE VI 83


20. State
• The State design pattern characterizes for
changing its behavior depending on the state
of the application.
• To achieve this, it’s necessary to create a
series of classes for representing the different
states an application can go through, that is,
one class for each state of the application.
7/13/2022 Design Pattern, OOSD, BSE VI 84
• Context: It represents the component subject
to changing states, it has its current state as
one of its properties. Going back to the
vending machine example, this would
represent the machine.
• AbstractState: Base class used for generating
different states. This works better as an
abstract class, instead of as an interface,
because it allows us to set behaviors by
default and alter the operation on every state.
• ConcreteState: Each one of these
components represent a state the application
could go through during its execution, which
is why we’re going to have a ConcreteState for
each possible state. This class must inherit
from AbstractState.

7/13/2022 Design Pattern, OOSD, BSE VI 85


1. A state by default is set in the
Context, this is StateA.
2. A request operation is executed
in the Context, delegating the
execution to the current state
(StateA).
3. The Context changes from StateA
to StateB.
4. Again, a request operation is
executed in the Context
delegating the execution to the
current state (StateB).
5. The execution of StateB results in
a change to StateC.
6. A new request operation is
executed in the Context
delegating the execution to the
current state (StateC).

7/13/2022 Design Pattern, OOSD, BSE VI 86


Real-world example
• By implementing the State design
pattern, we are going to create
our own server, which will be
control through a series of states.
• These states will tell the server
how to behave under different
events, because the same event
can provide different results
depending on the current state
of the server.

7/13/2022 Design Pattern, OOSD, BSE VI 87


21. Strategy
• The strategy design pattern allows us to set
the behavior of a class at runtime.
• Strategy bases on polymorphism for
implementing a series of behaviors that can
be interchanged during the execution of the
program, allowing for a modification of an
object’s behavior by following a strategy that
has been set.
7/13/2022 Design Pattern, OOSD, BSE VI 88
• Context: This component
encapsulates the strategy
to be used, which can be
set at runtime.
• IStrategy: Common
interface all strategies
must implement. In it, all
the operations the
strategies need to
implement are defined.
• ConcreteStrategy: It
represents the concrete
strategies, which inherit
from IStrategy.

7/13/2022 Design Pattern, OOSD, BSE VI 89


1. The client creates a new context and
sets the StrategyA.
2. The client executes the
doSomethingoperation.
3. Context hands over this responsibility
to ConcreteStrategyA.
4. ConcreteStrategyA performs the
operation and returns the result.
5. Context takes this result and hands it
over to the client.
6. The client changes the Context strategy
at runtime.
7. The client executes the
doSomethingoperation again.
8. Context hands over this responsibility
to ConcreteStrategyB.
9. ConcreteStategyB performs the
operation and returns the result.
10. Context takes this result and hands it
over to the client.

7/13/2022 Design Pattern, OOSD, BSE VI 90


• Real-world example
• By implementing the Strategy
design pattern, we are going to
develop an application that offers
different authentication methods.
• User authentication will be
achieved via XML file, database or
settings file in memory.
• With the Strategy pattern, the user
will be able to establish the
preferred authentication method in
the application, without having to
add any more code.

7/13/2022 Design Pattern, OOSD, BSE VI 91


22. Visitor
• The Visitor design pattern is used for separating the logic and
operations performed over a complex structure.
• On occasions, we can find data structures requiring various
operations to be performed and needing new ones to be created as
the application grows.
• As the application grows, so does the number of operations
included in the structure, making it very difficult to manage.
• This is where the Visitor design patterns enters, it proposes the
separation of these operations into independent classes called
Visitors, created with a common interface and a basic structure for
adding operations without having to make modifications to it.

7/13/2022 Design Pattern, OOSD, BSE VI 92


• Client: Component interacting with the
structure (element) and with the Visitor
pattern, this is the one in charge of creating
the visitors and sending to the element.
• Element: It represents the root of the tree
structure in which the Visitor pattern will be
implemented. This object is typically an
interface with accept method defined, which
must be implemented by all objects in the
structure.
• ConcreteElement: It represents a child of the
built structure. The entire structure may be
compounded of many of these objects, and
each and every one of them must have the
accept method implemented.
• IVisitor: Interface defining the structure of the
visitor, it must have a method for each object
of the structure (element) requiring to be
analyzed.
• ConcreteVisitor: It represents an
implementation of the visitor. This
implementation can perform operations over
the element. It is possible to have as many
ConcreteVisitor as we need for performing the
various operations we need.

7/13/2022 Design Pattern, OOSD, BSE VI 93


1. The client creates the structure
(Element).
2. The client creates the instance of
the Visitor to be used in the
structure.
3. The client executes the accept
method of the structure and sends
the Visitor.
4. The Element tells the Visitor which
method must be used for
processing it. The Visitor must have
a method for each class type
included in the structure.
5. The Visitor analyzes the Element
using its visitElement method and
repeats the accept method
execution process over the
Element's children. Again, the
Visitor must have a method for
each class type included in the
structure.

7/13/2022 Design Pattern, OOSD, BSE VI 94


6. The ConcreteElementA tells the Visitor visitor
which method must be used for processing it,
that is visitElementA.
7. The Visitor proceeds with the rest of the
children of the Element and executes the
accept method on ConcreteElementB.
8. The ConcrteElementB tells the Visitor which
method must be used for processing it, that is
visitElementB.
9. Lastly, the Visitor ends the operation
performed over the structure after having
traversed all the objects, providing results
available for the client by request using the
getResults method (this is optional, because
some operations won't produce any results).

7/13/2022 Design Pattern, OOSD, BSE VI 95


Real-world example
• By implementing the Visitor
design pattern, we are going
to review how a plan to build
a Microsoft Project type
project is analyzed and
evaluated to get the
information we require.
• To that end, we will develop a
work plan which includes
activities and personnel
forming a hierarchical
structure similar to a tree.

7/13/2022 Design Pattern, OOSD, BSE VI 96


23. Template Method
• The template design pattern focuses on code
reutilization for implementing steps to solve
problems.
• This is achieved by implementing base classes for
defining basic behaviors.
• Typically, methods are created for each step of
the algorithm; some of these will be
implemented while others remain abstract until
they are executed by the subclasses.

7/13/2022 Design Pattern, OOSD, BSE VI 97


• Client: It's the component which
triggers the execution of the
template.
• AbstractTemplete: It's an abstract
class including a series of
operations which define the
necessary steps for carrying out
the execution of the algorithm.
This class has a templateMethod
method for executing step1, step2
and step3 in order.
• Implementation: This class
represents a concrete template
which inherits from
AbstractTemplate and implements
its methods.

7/13/2022 Design Pattern, OOSD, BSE VI 98


1. The client creates and gets
an instance of the template
implementation.
2. The client executes the
templateMethod .
3. The default
implementation of
templateMethod executes
the step1, step2,
step3methods in order.
4. The template
implementation returns a
result.

7/13/2022 Design Pattern, OOSD, BSE VI 99


• Real-world example
• By implementing the Templete Method
design pattern, we are going to develop an
application for processing payment files.
• These files are generated by grocery stores
or convenience stores where the
customers can pay services, such as
electricity, water, cable, internet, phone,
etcetera.
• At the end of each day, these stores would
generate a plain text file to be sent to the
respective companies in order for them to
process the payments.
• With the Template pattern, we will learn
how to process any type of file in a clear,
simple and generic manner.

7/13/2022 Design Pattern, OOSD, BSE VI 100


D. Other Patterns:
1. Player Role pattern
2. Concurrency Pattern
3. Real-time patterns
4. Enterprise patterns
5. Data Access Patterns

7/13/2022 Design Pattern, OOSD, BSE VI 101


1. Player Role Patterns:
• Context:
– A role is a particular set of properties associated with an object in a
particular context. An object may play different roles in different
contexts.
– Example: A student cane be either part time or full time, and can
change from one to another.

• Problem:
– Find the best way to model players and roles so that a player can
change roles or posses multiple roles.
– We want to avoid multiple inheritance
– We cannot allow an instance to change class.

7/13/2022 Design Pattern, OOSD, BSE VI 102


Player Role Patterns:
• Solution:
– Create a class <<Player>> to represent objects that play roles
– Create an association from this class to an abstract <<Role>> class, a super-class of all
possible roles,
– Subclasses of <<Role>> encapsulate the properties and behaviors with different roles.
– Multiplicity can be one-to-one or one-to-many.
– Instead of being an abstract class, the «Role» can be an interface.

7/13/2022 Design Pattern, OOSD, BSE VI 103


Player Role Patterns:

7/13/2022 Design Pattern, OOSD, BSE VI 104


2. Concurrency Design Patterns:
• In software engineering, concurrency patterns are those types of design
patterns that deal with the multi-threaded programming paradigm.
• Examples of this class of patterns are:
– Active Object Pattern
– Balking Pattern
– Barrier
– Double-checked locking
– Guarded Suspension
– Read Write Lock pattern
– Thread pool pattern and so on.
Reference: https://en.wikipedia.org/wiki/Concurrency_pattern
https://www.youtube.com/watch?v=a6TNZgqqJlg
https://www.youtube.com/watch?v=kfr49sS-
FNE&list=PLmCsXDGbJHdhSdIWc9a4_ZXgqS0kvPX4t
7/13/2022 Design Pattern, OOSD, BSE VI 105
The Thread pool pattern
• It is one of the concurrency design
pattern.
• The thread pool pattern is where a
number of threads are created to
perform a number of tasks, which are
usually organized in a queue.
• Typically, there are many more tasks
than threads.
• As soon as a thread complete its task,
it will request the next task from the
queue until all tasks have been
completed. A sample thread pool (green boxes) with
waiting tasks (blue) and completed tasks
• The thread can then terminate, or (yellow)
sleep until there are new tasks
available.
Source: https://en.wikipedia.org/wiki/Thread_pool

7/13/2022 Design Pattern, OOSD, BSE VI 106


Message Queuing Pattern

7/13/2022 Design Pattern, OOSD, BSE VI 107


Assignment:
• Describe each in brief:
– The Data-Access Pattern
– Enterprise Pattern
– Real-time patterns
• Advantages and Disadvantages of Design
Pattern

7/13/2022 Design Pattern, OOSD, BSE VI 108


3.5 Documenting and Describing Patterns
• Pattern Name and Classification: A descriptive and unique name that helps
in identifying and referring to the pattern.
• Intent: A description of the goal behind the pattern and the reason for
using it.
• Also Known As: Other names for the pattern.
• Motivation (Forces): A scenario consisting of a problem and a context in
which this pattern can be used.
• Applicability: Situations in which this pattern is usable; the context for the
pattern.
• Structure: A graphical representation of the pattern. Class diagrams and
Interaction diagrams may be used for this purpose.
• Participants: A listing of the classes and objects used in the pattern and
their roles in the design.

7/13/2022 Design Pattern, OOSD, BSE VI 109


• Collaboration: A description of how classes and objects used in the pattern
interact with each other.
• Consequences: A description of the results, side effects, and trade offs
caused by using the pattern.
• Implementation: A description of an implementation of the pattern; the
solution part of the pattern.
• Sample Code: An illustration of how the pattern can be used
in a programming language
• Known Uses: Examples of real usages of the pattern.
• Related Patterns: Other patterns that have some relationship with the
pattern; discussion of the differences between the pattern and similar
patterns.

7/13/2022 Design Pattern, OOSD, BSE VI 110


3.6 Criticism
• The concept of design patterns has been criticized
by some in the field of computer science.
• Below is the criticism for Design patterns:
– Targets the wrong problem:
• The design patterns may just be workarounds of some missing
features of a given language.
– Lacks formal foundations:
• The study of design patterns has been excessively ad-hoc
– Leads to inefficient solutions,
– Does not differ significantly from other abstractions.
7/13/2022 Design Pattern, OOSD, BSE VI 111
Exam questions:
1. Design patterns have to be applied using some programming language. Discuss the statement in the light of
programming paradigm versus design patterns. Take any two patterns with an example to prove your point. [PU
2015 Spring]
2. What is the role of design patterns? Take any two patterns with an example to prove your point. [PU 2015 Spring]
3. Write about structure and documentation of pattern. [PU 2015 Spring]
4. Define design principle, design concept and design pattern. What are the disadvantages of design patterns? [PU
2015 Spring]
5. Design the four-dimensional view of a system. Justify along with design concepts. [PU 2016 Fall]
6. Define design pattern. How is design pattern important? Is software development possible without applying
design pattern? [PU 2016 Fall]
7. Describe a suitable design pattern for following problem. “what is the best way to represent related objects
(occurrence) in a class diagram”? [PU 2016 Fall]
8. Define design principle, design concept and design pattern. What are the disadvantages of design pattern? [PU
2016 Fall]
9. Describe Player-Role pattern. [PU 2016 Spring]
10. Read following problem and suggest a design pattern with relevant information. Problem: How so you ensure that
it is never possible to create more than one instance of a single class? [PU 2016 Spring]

7/13/2022 Design Pattern, OOSD, BSE VI 112


3.6 Criticism
11. Can anyone build software without implementing design pattern? What are advantages of
using design pattern? [PU 2016 Spring]
12. List and describe the principles that leads to good design in brief. [PU 2016 Spring]
13. What is Design Pattern? Write about importance of Design Patterns. [PU 2017 Spring]
14. Describe Structural Design Pattern. [PU 2017 Spring]
15. Write about structure and documentation of pattern. [PU 2017 Spring]
16. Explain about Singleton pattern along with code in any suitable programming language (C++
or Java or C#). [PU 2017 Spring]
17. What is design patterns? Write about importance of Design patterns. [PU 2017 Fall]
18. Describe Creational pattern. [PU 2017 Fall]
19. Write about structure and documentation of pattern. [PU 2017 Fall]
20. Explain about Player-Role pattern. [PU 2017 Fall]

7/13/2022 Design Pattern, OOSD, BSE VI 113


21. What so you mean by Creational Pattern? Explain any one of its type with DCD and
source code snippet. [PU 2018 Spring]
22. What is Design pattern? Write about importance of Design Patterns. [PU 2018 Spring]
23. What are the difficulties and risks while using design pattern? Discuss in brief. [PU
2018 Spring]
24. Explain about concurrency pattern. [PU 2018 Spring]
25. What is Design pattern? Write about importance of Design Patterns. [PU 2019 Fall]
26. Explain about Behavioral pattern. [PU 2019 Fall]
27. Explain about concurrency pattern. [PU 2019 Fall]
28. Write about Structure and Documentation of pattern. [PU 2019 Fall]
29. What is Design Pattern? Write about importance of Design Patterns. [PU 2019 Spring]
30. Explain Singleton pattern along with its UML class diagram. [PU 2019 Spring]

7/13/2022 Design Pattern, OOSD, BSE VI 114


31. Explain advantages and uses of Façade design pattern with its UML representation. [PU 2019
Spring]
32. Explain Observer pattern along with its UML class diagram. [PU 2019 Spring]
33. In object-oriented software development, which design pattern is used to provide object
creation mechanism? Explain it and its types with their applicability. [PU 2020 Spring]
34. Why do we need design pattern is software development? Explain the documentation of design
patterns. [PU 2020 Spring]
35. What is Design pattern? Write about importance of Design patterns. [PU 2020 Fall]
36. Explain about Interpreter pattern along with its UML representation. [PU 2020 Fall]
37. Write about concurrency pattern. [PU 2020 Fall]
38. Write short notes on:
a) Player-role design pattern [PU 2015 Spring , PU 2016 Fall]
b) Importance of design pattern [PU 2016 Spring]
c) Observer Pattern [PU 2017 Spring]
d) Singleton pattern [PU 2017 Fall]
e) Real-Time Pattern. [PU 2019 Spring]
f) Real time pattern [PU 2020 Fall]

7/13/2022 Design Pattern, OOSD, BSE VI 115


End of Chapter

7/13/2022 Design Pattern, OOSD, BSE VI 116

You might also like