SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

PATTERNS03 - Behavioural Design Patterns
PATTERNS03 - Behavioural Design PatternsPATTERNS03 - Behavioural Design Patterns
PATTERNS03 - Behavioural Design PatternsMichael Heron
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsMichael Heron
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSergey Aganezov
 
Creational pattern
Creational patternCreational pattern
Creational patternHimanshu
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design PatternsLidan Hifi
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)paramisoft
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISEsreeja_rajesh
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3Naga Muruga
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternShahriar Hyder
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 
A&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLA&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLvinay arora
 
Design Pattern
Design PatternDesign Pattern
Design PatternHimanshu
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsHayim Makabee
 

La actualidad más candente (20)

PATTERNS03 - Behavioural Design Patterns
PATTERNS03 - Behavioural Design PatternsPATTERNS03 - Behavioural Design Patterns
PATTERNS03 - Behavioural Design Patterns
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Sda 8
Sda   8Sda   8
Sda 8
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design Patterns
 
Creational Design Patterns
Creational Design PatternsCreational Design Patterns
Creational Design Patterns
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
 
Softwaredesignpatterns ppt-130430202602-phpapp02
Softwaredesignpatterns ppt-130430202602-phpapp02Softwaredesignpatterns ppt-130430202602-phpapp02
Softwaredesignpatterns ppt-130430202602-phpapp02
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
Ch08lect2 ud
Ch08lect2 udCh08lect2 ud
Ch08lect2 ud
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
A&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLA&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UML
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design Patterns
 

Destacado

PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsAmir Barylko
 
Recommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentRecommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentFrancis Palma
 
PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patternsAmir Barylko
 
Unity - Software Design Patterns
Unity - Software Design PatternsUnity - Software Design Patterns
Unity - Software Design PatternsDavid Baron
 
Implementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBImplementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBWSO2
 
Software Design Patterns in Practice
Software Design Patterns in PracticeSoftware Design Patterns in Practice
Software Design Patterns in PracticePtidej Team
 
Advanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterAdvanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterWeaveworks
 

Destacado (9)

PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patterns
 
Recommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentRecommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software Development
 
PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Unity - Software Design Patterns
Unity - Software Design PatternsUnity - Software Design Patterns
Unity - Software Design Patterns
 
Implementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBImplementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESB
 
Software Design Patterns in Practice
Software Design Patterns in PracticeSoftware Design Patterns in Practice
Software Design Patterns in Practice
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Advanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterAdvanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriter
 

Similar a Software Design Patterns

Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptSanthosh Kumar Srinivasan
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternsbonej010
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane2
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software EngineeringAmit Singh
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns StructuralUMAR ALI
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanPriyanka Pradhan
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsMohammad Shaker
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityShubham Narkhede
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their applicationHiệp Tiến
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptxSachin Patidar
 

Similar a Software Design Patterns (20)

Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Introduction to Design Patterns in Javascript
Introduction to Design Patterns in JavascriptIntroduction to Design Patterns in Javascript
Introduction to Design Patterns in Javascript
 
Design patterns
Design patternsDesign patterns
Design patterns
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
designpatterns-.pdf
designpatterns-.pdfdesignpatterns-.pdf
designpatterns-.pdf
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software Engineering
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns Structural
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design Patterns
 
Patterns
PatternsPatterns
Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 

Último

Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 

Último (20)

Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 

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.