0% found this document useful (0 votes)
20 views27 pages

Lesson 7

Uploaded by

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

Lesson 7

Uploaded by

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

Software Design

Patterns
What are Design Patterns?

• Reusable solutions to common software


problems
• Improve software scalability, flexibility, and
maintainability
• Introduced by the “Gang of Four” (GoF) in
1994 by Erich Gamma, Richard Helm, Ralph
Johnson, and John Vlissides.
Categories of
Design Patterns
Creational Patterns
This deals with object
creation
Structural Patterns
This handle
relationships between
entities
Behavioral
Patterns
This focuses on
communication
between objects
Creational Design
Patterns
This principle encapsulates object creation. It
covers the following patterns: Singleton, Abstract
Factory, Builder, and Prototype
Singleton Pattern
It ensures only one
instance of a class exists
and can be used to a
Configuration manage
Abstract Factory
Pattern
This create families of
related objects without
specifying their concrete
classes which can be used
to GUI libraries for multiple
platforms
Builder Pattern
It is used to construct
complex objects step by
step, separating the
construction process from
its representation.
Prototype Pattern
It is used to create new objects by
copying an existing object
(prototype) instead of creating
from scratch which is to duplicate
complex objects (e.g., shapes in a
graphics editor) without going
through the expensive process of
creating a new instance.
Structural Design
Patterns
This principle focuses on relationships among
objects to form complex structures. It covers the
following patterns: Adapter, Proxy, Façade,
Decorator, Composite
Façade Pattern
This simplify interaction
with complex systems
which provides unified
interface to subsystems
Adapter Pattern
This allows incompatible interfaces
to work together by converting the
interface of a class into another
expected by the client. Example is
integration of a legacy system with
a new system, such as making an
old payment processing API work
with a modern interface
Proxy Pattern
This provides a surrogate or
placeholder for another object to
control access, enhance
functionality, or manage resources
which is Controlling access to a
resource-intensive object like a
large image that is loaded only
when needed (lazy initialization).
Decorator Pattern
This dynamically add or modify
behavior of an object without
altering its structure by wrapping
it with other objects, such as
adding features like scrollbars or
borders to a graphical window
object without modifying the
window's code
Composite Pattern
It is used to compose objects into
tree-like structures to represent
part-whole hierarchies, allowing
clients to treat individual objects
and compositions uniformly which
represents a folder structure in a file
system, where both files and folders
can be treated the same way
Behavioral Design
Patterns
This principle manages object communication and
control workflow. It covers the following patterns:
Observer, State, Command, Strategy
Observer Pattern
It is used to notify
dependent objects when
state changes which is
used in event handling in
GUIs
State Pattern
It is used to change object
behavior based on its state
which can be used in
elevator operations
modeled with states
Command Pattern
This encapsulates a request as an
object, allowing for parameterization
of clients with queues, logs, and
operations, and supporting undoable
actions resulting to implementation of
an "Undo" functionality in text editors,
where each action (e.g., typing,
deleting) is encapsulated as a
command
Strategy Pattern
It is used to define a family of
algorithms, encapsulate each one,
and make them interchangeable so
that the algorithm can vary
independently from the client using it.
Example is: Sorting algorithms in a
program, where you can switch
between strategies like quicksort,
mergesort, or bubblesort at runtime
Key Design Principles Behind
Patterns

● Encapsulation of Variability: Keep changes


isolated in modules
● Polymorphism & Interfaces: Dynamically
bind to implementations
● Low Coupling & High Cohesion: Reduce
dependencies
GRASP
Principles and
Patterns
What is GRASP?
General Responsibility
Assignment Software
Patterns
When to Use (or Not Use) Design
Patterns

Appropriate Use: Overuse Concern:

• Solutions to recurring • Avoid using patterns


problems just for the sake of
• When abstraction elegance
improves flexibility
Thank
you!

You might also like