SlideShare a Scribd company logo
SOFTWARE DESIGN PATTERNS
Introduction
Often wondered, on large/complex projects if we
were to change a small part, wouldn’t be tedious to
change the entire code inorder to get the required
results?
Well, for such situations we have an adopted
concept which is “Software Design Patterns”. When
described in terms of software engineering, a design
pattern is a general reusable solution for a commonly
occurring problem within a given context of a software
design.
Object-oriented design patterns showcases the
relationships and interactions between classes/objects,
without specifying the final application classes or objects
that are involved. Software Design Patterns is viewed as
a structured approach for programming intermediate
between the levels of a programming paradigm and a
concrete algorithm.
Categories
Design patterns can be categorised into three
fundamental groups, as follows:-
1. Structural Patterns
2. Creational Patterns
3. Behavioral Patterns
Let's see in detail each of the patterns in the next slides.
Structural Patterns
• In Structural patterns, larger structures are formed from
individual parts, which are generally of different classes.
• The main concern associated with these patterns is with
how classes and objects are composed to form larger
structures.
• In these patterns, inheritance is used to compose
interfaces or implementations.
• Consider a simple example, like how multiple
inheritance mixes together two or more classes
into one. The result would be a class that
combines the properties of its parent classes.
• The usefulness of this pattern is for making
independently developed class libraries work
together.
Methods in Structural Patterns
• Adapter:
An adapter allows classes to work together which could
not otherwise because of incompatible interfaces.
• Bridge:
Seprates or decouples an abstraction from its
implementation allowing them to vary independently.
• Composite:
Composite divides objects into tree structures inorder
to represent part-whole hierarchies.
• Decorator:
Adds additional responsibilities for an object
dynamically while keeping the same interface.
• Facade:
Facade specifies a high-level interface that makes the
subsystem easier to use.
• Flyweight:
Sharing is used to support large numbers of similar
objects efficiently and effectively.
• Front Controller:
Usually related to the design of Web applications.
• Module:
Several related elements, like classes, singletons,
methods, globally used, are grouped into a single
conceptual entity.
• Proxy:
Provides a placeholder for a different object in order
to control access to it.
Creational Patterns
• Creational patterns are generally used to create objects
for suitable classes that serve as a solution for a
problem,usually when instances of several different
classes are available.
• These patterns are particularly useful while taking
advantage of polymorphism and also when there is a
need to choose between different classes at run-time
rather than compile time.
Methods in Creational Patterns
• Abstract Factory:
This provides an interface for creating families of
dependent objects without specifying their concrete
classes.
• Builder:
The construction of a complex object from its
representation, allowing the same construction
process to create various representations.
• Multiton:
Makes sure a class has only named instances.
• Factory Method:
Defines an interface to create a single object, but also
lets subclasses decide which classes to instantiate.
• Lazy initialization:
This is a tactic of delaying the creation of an object
• Object pool:
Recycles objects that are no longer in use.
• Prototype:
Specifies the objects for creating a prototypical
instance, and also to create new objects by copying
this prototype.
• Singleton:
Makes sure a class only has one instance, and
thence provides a global point of access to it.
• Design pattern object library:
Wraps up object management together with factory
interface including live and dead lists.
Behavioral Patterns
• These patterns usually deals with interactions between
objects and focuses on how objects communicates with
each other.
• They can reduce the complex flow charts into mere
interconnections between objects of various classes.
• Behavioral patterns are also used to make the algorithm
that a class uses simply another parameter that is
adjustable at run-time.
Methods in Behavioral Patterns
• Chain of responsibility:
Avoids coupling the sender of a request to its receiver by
giving more than one object a chance to handle the
request.
• Command:
An object is encapsulated as a request.
• Interpreter:
Represents interpreted sentences into the corresponding
language.
• Iterator:
Provides a solution to access the elements of an object
sequentially,without exposing its underlying
representation.
• Mediator:
Sets an object that encapsulates and describes how a
set of objects interact.
• Memento:
This method allows to capture and externalize an
object's internal state and also allowing it to be
restored to this state later.
• Null object:
Default object is provided by avoiding null references.
• Observer:
Defines a one-to-many dependency between objects,
where a state change in one of the object results in all
its dependent objects being notified and updated
automatically.
• Servant:
Defines the similar functionality for a group of classes.
• Specification:
Combines business logic within a boolean representation.
• State:
Allowing the objects to alter their behavior simultaneosly
when its internal state changes.
• Strategy:
Sets a family of algorithms, encapsulate each one, and
makes them interchangeable.
• Template method:
Skeleton of an algorithm is defined in an operation.
• Visitor:
Representing an operation to be performed on the
elements of an object structure.
Practice / Example
A simple example involves using the Factory Method of
the Creational Patterns.
//Gallery.cfc
interface {
public any function getPhotos();
}
An interface is used with a declaration of getPhotos()
function.
//UserGallery.cfc
component implements="Gallery"
{
public any function getPhotos()
{
qry=new Query(sql="select * from
usergallery",datasource="dk");
return qry.execute().getResult();
}
}
This file has a component which implements the above interface Gallery,
and also defines the function getPhotos(). Within the function various
data are selected from the usergallery table.
//PicasaGallery.cfc
component interface="Gallery" {
public any function getPhotos() {
qry=new Query("Select name from
PicasaGallery",datasource="dk");
return qry.execute().getResult();
}
}
Within this file, again Gallery interface has been
implemented together with the function getPhotos()
definition. In this function the name is obtained from the
PicasaGallery table.
//AdminGallery.cfc
component interface="Gallery" {
public any function getPhotos() {
qry=new Query("Select name from
AdminGallery",datasource="dk");
return qry.execute().getResult();
}
}
In this file, the Gallery interface has also been implemented,
and the definition of the getPhotos() function includes
getting the name from AdminGallery table.
//FactoryGallery.cfc
component
{
public any function getGallery(name)
{
gallery="";
if(name=="User")
{
gallery=createObject("component",
"Design_Patterns.UserGallery");
}
else if(name=="Picasa")
{
gallery=createObject("component",
"Design_Patterns.PicasaGallery");
}
(...contd)
else if(name=="Admin"){
gallery=createObject("component",
"Design_Patterns.AdminGallery");
}
return gallery;
}
}
FactoryGallery.cfc creates a getGallery() function which
is used to create objects of components UserGallery,
PicassaGallery, and AdminGallery.
//MyGallery.cfm
<cfscript>
my_gallery=createObject("component",
"Design_Patterns.FactoryGallery");
my_photos=my_gallery.getGallery("User").getPhotos();
writeDump(my_photos);
</cfscript>
The final results can be viewed in this above file. The object of
FactoryGallery is created and with it the getPhotos() function is
accessed, and the results are dumped to view the results.
So in short......
• If we want add additional galleries, we only need to do 2
things:
– Create a component and implement it in the Gallery
interface.
– Add the new created component into the
FactoryGallery.cfc, within the
getGallery() function.
• The advantage of using this factory method is that,
changes are only made in two places: FactoryGallery
and MyGallery. Usually the exact use is visible for
complex projects.

More Related Content

PPT
Introduction to design patterns
PDF
Design Patterns Presentation - Chetan Gole
PPT
Design Pattern For C# Part 1
PPTX
Gof design patterns
PDF
Gof design pattern
PPTX
Software design patterns ppt
PPTX
Let us understand design pattern
PDF
Design patterns
Introduction to design patterns
Design Patterns Presentation - Chetan Gole
Design Pattern For C# Part 1
Gof design patterns
Gof design pattern
Software design patterns ppt
Let us understand design pattern
Design patterns

What's hot (20)

PDF
Introduction to Design Pattern
PPTX
Design Patterns - General Introduction
PPTX
Delegates and events in C#
PPT
Working with frames
PPTX
Design concept -Software Engineering
PPTX
Design Pattern - Singleton Pattern
PPTX
Solid principles
PPTX
Unified process Model
PPT
Introduction to Design Patterns and Singleton
PPT
Uml class diagram and packages ppt for dot net
PPT
Design patterns ppt
PDF
Angular - Chapter 1 - Introduction
PPTX
Java abstract class & abstract methods
PPTX
Exception Handling in C#
PPT
Abstract class
PPTX
Design patterns
PPTX
Software Architecture
PPTX
Java - Collections framework
PPTX
Design pattern-presentation
PDF
Software Patterns
Introduction to Design Pattern
Design Patterns - General Introduction
Delegates and events in C#
Working with frames
Design concept -Software Engineering
Design Pattern - Singleton Pattern
Solid principles
Unified process Model
Introduction to Design Patterns and Singleton
Uml class diagram and packages ppt for dot net
Design patterns ppt
Angular - Chapter 1 - Introduction
Java abstract class & abstract methods
Exception Handling in C#
Abstract class
Design patterns
Software Architecture
Java - Collections framework
Design pattern-presentation
Software Patterns
Ad

Viewers also liked (9)

PPT
Design Patterns
PPTX
My life plans
PDF
Design Patterns : The Ultimate Blueprint for Software
PDF
Software Security
PPT
Software security
PPS
Design Patterns For 70% Of Programmers In The World
PPT
Design Patterns (Examples in .NET)
PPTX
PDF
Design Patterns Illustrated
Design Patterns
My life plans
Design Patterns : The Ultimate Blueprint for Software
Software Security
Software security
Design Patterns For 70% Of Programmers In The World
Design Patterns (Examples in .NET)
Design Patterns Illustrated
Ad

Similar to Software Design Patterns (20)

PDF
software engineering Design Patterns.pdf
PPTX
ap assignmnet presentation.pptx
PDF
Design Patterns Java programming language.pdf
DOCX
Design patterns
PDF
Design Pattern in Software Engineering
PPTX
Sofwear deasign and need of design pattern
PDF
designpatterns-.pdf
PPTX
Design patterns
PPT
Chapter 4_Introduction to Patterns.ppt
PPT
Chapter 4_Introduction to Patterns.ppt
PPT
Design Patterns
PPTX
PPTX
OOPSDesign PPT ( introduction to opps and design (
PPTX
Software Patterns
DOCX
Design Pattern Notes: Nagpur University
PPT
Design pattern
PPTX
Design pattern and their application
PPTX
UNIT IV DESIGN PATTERNS.pptx
PDF
Module 4: UML In Action - Design Patterns
PPTX
Design patterns
software engineering Design Patterns.pdf
ap assignmnet presentation.pptx
Design Patterns Java programming language.pdf
Design patterns
Design Pattern in Software Engineering
Sofwear deasign and need of design pattern
designpatterns-.pdf
Design patterns
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
Design Patterns
OOPSDesign PPT ( introduction to opps and design (
Software Patterns
Design Pattern Notes: Nagpur University
Design pattern
Design pattern and their application
UNIT IV DESIGN PATTERNS.pptx
Module 4: UML In Action - Design Patterns
Design patterns

Recently uploaded (20)

DOCX
Looking for a Tableau Alternative Try Helical Insight Open Source BI Platform...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Understanding NFT Marketplace Development_ Trends and Innovations.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Essential Infomation Tech presentation.pptx
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administraation Chapter 3
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
medical staffing services at VALiNTRY
PDF
Digital Strategies for Manufacturing Companies
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Introduction to Artificial Intelligence
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Mini project ppt template for panimalar Engineering college
DOCX
The Five Best AI Cover Tools in 2025.docx
Looking for a Tableau Alternative Try Helical Insight Open Source BI Platform...
PTS Company Brochure 2025 (1).pdf.......
Understanding NFT Marketplace Development_ Trends and Innovations.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Essential Infomation Tech presentation.pptx
ManageIQ - Sprint 268 Review - Slide Deck
Materi_Pemrograman_Komputer-Looping.pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administraation Chapter 3
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Softaken Excel to vCard Converter Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
medical staffing services at VALiNTRY
Digital Strategies for Manufacturing Companies
Which alternative to Crystal Reports is best for small or large businesses.pdf
Introduction to Artificial Intelligence
A REACT POMODORO TIMER WEB APPLICATION.pdf
Mini project ppt template for panimalar Engineering college
The Five Best AI Cover Tools in 2025.docx

Software Design Patterns

  • 2. Introduction Often wondered, on large/complex projects if we were to change a small part, wouldn’t be tedious to change the entire code inorder to get the required results? Well, for such situations we have an adopted concept which is “Software Design Patterns”. When described in terms of software engineering, a design pattern is a general reusable solution for a commonly occurring problem within a given context of a software design.
  • 3. Object-oriented design patterns showcases the relationships and interactions between classes/objects, without specifying the final application classes or objects that are involved. Software Design Patterns is viewed as a structured approach for programming intermediate between the levels of a programming paradigm and a concrete algorithm.
  • 4. Categories Design patterns can be categorised into three fundamental groups, as follows:- 1. Structural Patterns 2. Creational Patterns 3. Behavioral Patterns Let's see in detail each of the patterns in the next slides.
  • 5. Structural Patterns • In Structural patterns, larger structures are formed from individual parts, which are generally of different classes. • The main concern associated with these patterns is with how classes and objects are composed to form larger structures. • In these patterns, inheritance is used to compose interfaces or implementations.
  • 6. • Consider a simple example, like how multiple inheritance mixes together two or more classes into one. The result would be a class that combines the properties of its parent classes. • The usefulness of this pattern is for making independently developed class libraries work together.
  • 7. Methods in Structural Patterns • Adapter: An adapter allows classes to work together which could not otherwise because of incompatible interfaces. • Bridge: Seprates or decouples an abstraction from its implementation allowing them to vary independently. • Composite: Composite divides objects into tree structures inorder to represent part-whole hierarchies.
  • 8. • Decorator: Adds additional responsibilities for an object dynamically while keeping the same interface. • Facade: Facade specifies a high-level interface that makes the subsystem easier to use. • Flyweight: Sharing is used to support large numbers of similar objects efficiently and effectively.
  • 9. • Front Controller: Usually related to the design of Web applications. • Module: Several related elements, like classes, singletons, methods, globally used, are grouped into a single conceptual entity. • Proxy: Provides a placeholder for a different object in order to control access to it.
  • 10. Creational Patterns • Creational patterns are generally used to create objects for suitable classes that serve as a solution for a problem,usually when instances of several different classes are available. • These patterns are particularly useful while taking advantage of polymorphism and also when there is a need to choose between different classes at run-time rather than compile time.
  • 11. Methods in Creational Patterns • Abstract Factory: This provides an interface for creating families of dependent objects without specifying their concrete classes. • Builder: The construction of a complex object from its representation, allowing the same construction process to create various representations. • Multiton: Makes sure a class has only named instances.
  • 12. • Factory Method: Defines an interface to create a single object, but also lets subclasses decide which classes to instantiate. • Lazy initialization: This is a tactic of delaying the creation of an object • Object pool: Recycles objects that are no longer in use.
  • 13. • Prototype: Specifies the objects for creating a prototypical instance, and also to create new objects by copying this prototype. • Singleton: Makes sure a class only has one instance, and thence provides a global point of access to it. • Design pattern object library: Wraps up object management together with factory interface including live and dead lists.
  • 14. Behavioral Patterns • These patterns usually deals with interactions between objects and focuses on how objects communicates with each other. • They can reduce the complex flow charts into mere interconnections between objects of various classes. • Behavioral patterns are also used to make the algorithm that a class uses simply another parameter that is adjustable at run-time.
  • 15. Methods in Behavioral Patterns • Chain of responsibility: Avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. • Command: An object is encapsulated as a request. • Interpreter: Represents interpreted sentences into the corresponding language. • Iterator: Provides a solution to access the elements of an object sequentially,without exposing its underlying representation.
  • 16. • Mediator: Sets an object that encapsulates and describes how a set of objects interact. • Memento: This method allows to capture and externalize an object's internal state and also allowing it to be restored to this state later. • Null object: Default object is provided by avoiding null references. • Observer: Defines a one-to-many dependency between objects, where a state change in one of the object results in all its dependent objects being notified and updated automatically.
  • 17. • Servant: Defines the similar functionality for a group of classes. • Specification: Combines business logic within a boolean representation. • State: Allowing the objects to alter their behavior simultaneosly when its internal state changes. • Strategy: Sets a family of algorithms, encapsulate each one, and makes them interchangeable.
  • 18. • Template method: Skeleton of an algorithm is defined in an operation. • Visitor: Representing an operation to be performed on the elements of an object structure.
  • 19. Practice / Example A simple example involves using the Factory Method of the Creational Patterns. //Gallery.cfc interface { public any function getPhotos(); } An interface is used with a declaration of getPhotos() function.
  • 20. //UserGallery.cfc component implements="Gallery" { public any function getPhotos() { qry=new Query(sql="select * from usergallery",datasource="dk"); return qry.execute().getResult(); } } This file has a component which implements the above interface Gallery, and also defines the function getPhotos(). Within the function various data are selected from the usergallery table.
  • 21. //PicasaGallery.cfc component interface="Gallery" { public any function getPhotos() { qry=new Query("Select name from PicasaGallery",datasource="dk"); return qry.execute().getResult(); } } Within this file, again Gallery interface has been implemented together with the function getPhotos() definition. In this function the name is obtained from the PicasaGallery table.
  • 22. //AdminGallery.cfc component interface="Gallery" { public any function getPhotos() { qry=new Query("Select name from AdminGallery",datasource="dk"); return qry.execute().getResult(); } } In this file, the Gallery interface has also been implemented, and the definition of the getPhotos() function includes getting the name from AdminGallery table.
  • 23. //FactoryGallery.cfc component { public any function getGallery(name) { gallery=""; if(name=="User") { gallery=createObject("component", "Design_Patterns.UserGallery"); } else if(name=="Picasa") { gallery=createObject("component", "Design_Patterns.PicasaGallery"); } (...contd)
  • 24. else if(name=="Admin"){ gallery=createObject("component", "Design_Patterns.AdminGallery"); } return gallery; } } FactoryGallery.cfc creates a getGallery() function which is used to create objects of components UserGallery, PicassaGallery, and AdminGallery.
  • 25. //MyGallery.cfm <cfscript> my_gallery=createObject("component", "Design_Patterns.FactoryGallery"); my_photos=my_gallery.getGallery("User").getPhotos(); writeDump(my_photos); </cfscript> The final results can be viewed in this above file. The object of FactoryGallery is created and with it the getPhotos() function is accessed, and the results are dumped to view the results.
  • 26. So in short...... • If we want add additional galleries, we only need to do 2 things: – Create a component and implement it in the Gallery interface. – Add the new created component into the FactoryGallery.cfc, within the getGallery() function. • The advantage of using this factory method is that, changes are only made in two places: FactoryGallery and MyGallery. Usually the exact use is visible for complex projects.