SlideShare a Scribd company logo
1 of 52
DESIGN PATTERN AND ITS
APPLICATIONS
BY
SWEKSHA PANDEY 11115041
GAYATRI THAKUR 11115028
Major project-2015 (NIT Raipur)
In our project we have implemented several softwares by taking
advantages of design patterns. We have used java and developed
several smaller softwares like calculator using factory pattern,
degree Fahrenheit conversion using adapter pattern, matching
colored shapes with its name using bridge pattern etc.
Main purpose of the project was to develop an interactive
platform for learning design pattern. So we have made a website
using php for learning design pattern and all the running
applications are attached to this tutorial.
Major project-2015 NIT Raipur
 To learn usage of design pattern and to take
advantages of design pattern in software development.
 Introducing modularity in softwares and making
code readable.
 Providing solution to common problem that may
appear during software development.
Major project-2015 NIT Raipur
Origin of design pattern
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.
Major project-2015 NIT Raipur
Common problems in software
development:
1. How to ensure that my class can be instantiated only once.
2. How to combine two incompatible classes.
3. How to decouple implementation of interface by different
classes
4. How to add additional functionality to a class without
changing functionality of existing class
Major project-2015 NIT Raipur
Design patterns are reusable solution to common problems
that software developers face during software development.
Design pattern is more advantageous if we use it with object
oriented programming languages like java and C++.
Major project-2015 NIT Raipur
Types of design pattern
There are many design patterns but all can be categorized
into three groups
1. Creational design pattern
2. Structural design pattern
3. Behavioral design pattern
Major project-2015 NIT Raipur
This design pattern provides the best possible way to create and
instantiate an object.
It provides a more flexible way to create an object and nature of
object can change with nature of program.
Three main types of creational design patterns are:
1.1. Singleton Design Pattern
1.2. Factory Method
1.3. Abstract Factory Method
Major project-2015 NIT Raipur
1.1 Singleton Pattern
Singleton is a class that can be instantiated only once. Hence only a
single instance of this class can be created.
It can be used at the places where we want to restrict creation of
multiple instances of a class.
Major project-2015 NIT Raipur
Singleton pattern: Implementation 1
This implementation contains server client application in which
server is using singleton class.
So client can request only one a single instance of server.
Major project-2015 NIT Raipur
(i) (ii)
(i) (ii)
(iii)
Major project-2015 NIT Raipur
1.2 Factory Method
A factory class instantiates and returns a particular type
of object based on the data passed to the factory.
A factory is a class that is used to encapsulate creation
code of object.
Major project-2015 NIT Raipur
Factory Method: Implementation 2
This implementation contains a simple calculator that is
developed using factory pattern.
When we pass data for a particular operator then factory
returns object for that operator.
That object is used for calling methods for that operator
Major project-2015 NIT Raipur
Binary Operation
.
Unary operation
Major project-2015 NIT Raipur
1.3 Abstract Factory Method
This factory is also known as factory of factories.
In abstract factory an interface is responsible for creating
factory of related object without specifying their classes.
Major project-2015 NIT Raipur
Abstract Factory: Implementation 3
This implementation consist of a small application in
which choosing an animal displays its family and details
about that animal.
Family is basically the factory returned by abstract
factory method.
Major project-2015 NIT Raipur
.
Major project-2015 NIT Raipur
Structural Patterns describe how objects and classes can be combined
to form larger structures. In software engineering, structural design
patterns are design patterns that ease the design by identifying a
simple way to realize relationships between entities.
Types of structural design patterns are:
2.1 Adapter pattern
2.2 Decorator pattern
2.3 Bridge pattern
2.4 Façade pattern
Major project-2015 NIT Raipur
2.1 Adapter Pattern
Adapter pattern works as a bridge between two
incompatible interfaces.
This pattern combines the capability of two independent
interfaces.
Major project-2015 NIT Raipur
Adapter Pattern: Implementation 4
In this implementation we have made a media player
which can play both .wav and .mp3 songs.
We are using an adapter class for combining features of
two types of songs.
Major project-2015 NIT Raipur
wav song
mp3 song
Major project-2015 NIT Raipur
2.2 Decorator Pattern
Decorator pattern allows a user to add new functionality
to an existing object without altering its structure.
This pattern creates a decorator class which wraps the
original class and provides additional functionality
keeping class methods signature intact.
Major project-2015 NIT Raipur
Decorator Pattern: Implementation 5
Here we have created an applet for depicting decorator
pattern. In this application clicking on buttons add extra
description to an existing description about an animal.
Major project-2015 NIT Raipur
.
Major project-2015 NIT Raipur
2.3 Bridge method
This pattern involves an interface which acts as a bridge
which makes the functionality of concrete classes
independent from interface implementer classes.
It decouples an abstraction from its implementation so that
the two can vary independently
Major project-2015 NIT Raipur
Bridge method: Implementation 6
This implementation contains colored shapes and a bridge
is maintained between color and shapes classes.
With the help of this bridge it is possible to match names
with colored shapes.
Major project-2015 NIT Raipur
.
Major project-2015 NIT Raipur
2.4 Façade Pattern
Façade is a face of the building.
It hides the complexities of the system and provides an
interface to the client from where the client can access
the system.
Major project-2015 NIT Raipur
Façade pattern: Implementation 7
This implementation contains an applet which calculate
2nd , 4th , 6th, 8th , and 9th root of a number. It uses façade
pattern to combine square root and cube root methods for
calculating other roots.
Major project-2015 NIT Raipur
.
Major project-2015 NIT Raipur
3. Behavioral design pattern
Major project-2015 NIT
Raipur
Behavioral design pattern provides a way to
communicate between objects , so it provides flexibility
for communication between objects by either creating
loose-coupling or hiding implementation detail to reduce
communication complexity.
3.1 Template Pattern
In Template pattern, an abstract class exposes defined
way(s)/template(s) to execute its methods.
Its subclasses can override the method implementation as
per need but the invocation is to be in the same way as
defined by an abstract class.
Major project-2015 NIT Raipur
Template Pattern: Implementation 8
This is a simple implementation in which template for
hockey and cricket are created and order of execution of
events are same in both.
Order of events are initialize the game, enjoy the game
and finish the game.
Major project-2015 NIT Raipur
.
Major project-2015 NIT Raipur
3.2Chain Responsibility Design Pattern
Major project-2015 NIT Raipur
It gives opportunities to the objects to handle
request.
Each object handle specific request.
For example:-Handling different numbers by positive
handler , negative handler and zero handler.
Chain : Implementation 9
Positive handler to handle positive numbers
Major project-2015 NIT Raipur
Handle negative number by handler
Major project-2015 NIT Raipur
3.3 Mediator Design Pattern
Major project-2015 NIT Raipur
Communication between two objects become more
complex because of internal structure of objects, so mediator
Used to create loose- coupling between objects.
For example application for communication between two
users:
Mediator: Implementation 10
Application for communication between two objects
Major project-2015 NIT Raipur
3.4 Strategy Design Pattern
Major project-2015 NIT Raipur
Handle multiple algorithms with in a class or change
execution at run time.
For example file compressor application:
This application used to compress file in GIP or GZIP
or RAR so it has class to handle multiple algorithms
and change execution at run time.
Strategy pattern : Implementation 11
file compressor
Major project-2015 NIT Raipur
3.5 Iterator Design Pattern
Major project-2015 NIT Raipur
Iterator design pattern is used to access data from large
collection of data.
Accessing data without exposing it’s internal data
structure.
For example accessing a channel from collection of channel
Iterator: Implementation 12
Application of iterator design pattern
Major project-2015 NIT Raipur
3.6 Interpreter design pattern
Major project-2015 NIT Raipur
This design pattern assign a value in place of complex
expression or grammar.
Like infix or postfix expression evaluated and assign a
specific value.
This pattern map a domain to a language, the language
to a grammar , a grammar to a object.
Interpreter pattern: Implementation 13
Application of interpreter design pattern: A parser from
roman to english digit
Major project-2015 NIT Raipur
3.7 Observer design pattern
Major project-2015 NIT Raipur
Observer design pattern is used to hold one-to-
many relationship between objects.
In this relation if one state change it will notify to
another observers.
For example suppose three observers to observe
Hexadecimal , octal , binary numbers:
Observer Pattern: Implementation 14
Application of observer design pattern
Major project-2015 NIT Raipur
Tutorial
Major project-2015 NIT Raipur
Purpose of tutorial
This tutorial has been prepared for the developers to
provide best solutions to certain problems faced during
software development and for un-experienced developers
to learn software design in an easy and faster way.
Major project-2015 NIT Raipur
Advantage of design pattern:
1.They are reusable in multiple projects.
2.They provide the solutions that help to define the system
architecture.
3.They capture the software engineering experiences.
4.They provide transparency to the design of an application.
5.They are well-proved and testified solutions since they have
been built upon the knowledge and experience of expert
software developers.
Major project-2015 NIT Raipur
Disadvantages of design pattern:
1. Complex in nature
2. Not always decrease understandability of design or
code. They can decrease understandability
3. Picking the correct design pattern and understanding
how to implement that pattern to our scenario is difficult.
Major project-2015 NIT Raipur
Thank you !!
Major project-2015 NIT Raipur

More Related Content

Similar to Design pattern

Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
MK_MSc_Degree_Project_Report ver 5_updated
MK_MSc_Degree_Project_Report ver 5_updatedMK_MSc_Degree_Project_Report ver 5_updated
MK_MSc_Degree_Project_Report ver 5_updatedMohammed Ali Khan
 
Automatic Graphical Design Generator
Automatic Graphical Design GeneratorAutomatic Graphical Design Generator
Automatic Graphical Design GeneratorIRJET Journal
 
Software enginneering
Software enginneeringSoftware enginneering
Software enginneeringchirag patil
 
Preliminry report
 Preliminry report Preliminry report
Preliminry reportJiten Ahuja
 
Unit 1 sepm process models
Unit 1 sepm process modelsUnit 1 sepm process models
Unit 1 sepm process modelsKanchanPatil34
 
Hybrid model for software development
Hybrid model for software developmentHybrid model for software development
Hybrid model for software developmenteSAT Journals
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering Bilal Hassan
 
CS587 Project - Raychaudhury,Shaalmali
CS587 Project - Raychaudhury,ShaalmaliCS587 Project - Raychaudhury,Shaalmali
CS587 Project - Raychaudhury,Shaalmalisagar.247
 
IT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docxIT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docxvrickens
 
Types of Software life cycle
Types of Software life cycleTypes of Software life cycle
Types of Software life cycleSanthia RK
 
IRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET Journal
 
The Architecture Of Software Defined Radios Essay
The Architecture Of Software Defined Radios EssayThe Architecture Of Software Defined Radios Essay
The Architecture Of Software Defined Radios EssayDivya Watson
 
Unleashing the Power of Generative AI.pdf
Unleashing the Power of Generative AI.pdfUnleashing the Power of Generative AI.pdf
Unleashing the Power of Generative AI.pdfTomHalpin9
 

Similar to Design pattern (20)

Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
MK_MSc_Degree_Project_Report ver 5_updated
MK_MSc_Degree_Project_Report ver 5_updatedMK_MSc_Degree_Project_Report ver 5_updated
MK_MSc_Degree_Project_Report ver 5_updated
 
Design patterns
Design patternsDesign patterns
Design patterns
 
GSOC 2016 mifos
GSOC 2016 mifosGSOC 2016 mifos
GSOC 2016 mifos
 
Automatic Graphical Design Generator
Automatic Graphical Design GeneratorAutomatic Graphical Design Generator
Automatic Graphical Design Generator
 
Software enginneering
Software enginneeringSoftware enginneering
Software enginneering
 
Preliminry report
 Preliminry report Preliminry report
Preliminry report
 
Unit 1 sepm process models
Unit 1 sepm process modelsUnit 1 sepm process models
Unit 1 sepm process models
 
Hybrid model for software development
Hybrid model for software developmentHybrid model for software development
Hybrid model for software development
 
Software process model
Software process modelSoftware process model
Software process model
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering
 
CS587 Project - Raychaudhury,Shaalmali
CS587 Project - Raychaudhury,ShaalmaliCS587 Project - Raychaudhury,Shaalmali
CS587 Project - Raychaudhury,Shaalmali
 
IT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docxIT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docx
 
SDLC MODEL
SDLC MODEL SDLC MODEL
SDLC MODEL
 
Types of Software life cycle
Types of Software life cycleTypes of Software life cycle
Types of Software life cycle
 
IRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET- Polymer Javascript
IRJET- Polymer Javascript
 
The Architecture Of Software Defined Radios Essay
The Architecture Of Software Defined Radios EssayThe Architecture Of Software Defined Radios Essay
The Architecture Of Software Defined Radios Essay
 
Unleashing the Power of Generative AI.pdf
Unleashing the Power of Generative AI.pdfUnleashing the Power of Generative AI.pdf
Unleashing the Power of Generative AI.pdf
 
Process models
Process modelsProcess models
Process models
 

Recently uploaded

Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 

Design pattern

  • 1. DESIGN PATTERN AND ITS APPLICATIONS BY SWEKSHA PANDEY 11115041 GAYATRI THAKUR 11115028 Major project-2015 (NIT Raipur)
  • 2. In our project we have implemented several softwares by taking advantages of design patterns. We have used java and developed several smaller softwares like calculator using factory pattern, degree Fahrenheit conversion using adapter pattern, matching colored shapes with its name using bridge pattern etc. Main purpose of the project was to develop an interactive platform for learning design pattern. So we have made a website using php for learning design pattern and all the running applications are attached to this tutorial. Major project-2015 NIT Raipur
  • 3.  To learn usage of design pattern and to take advantages of design pattern in software development.  Introducing modularity in softwares and making code readable.  Providing solution to common problem that may appear during software development. Major project-2015 NIT Raipur
  • 4. Origin of design pattern 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. Major project-2015 NIT Raipur
  • 5. Common problems in software development: 1. How to ensure that my class can be instantiated only once. 2. How to combine two incompatible classes. 3. How to decouple implementation of interface by different classes 4. How to add additional functionality to a class without changing functionality of existing class Major project-2015 NIT Raipur
  • 6. Design patterns are reusable solution to common problems that software developers face during software development. Design pattern is more advantageous if we use it with object oriented programming languages like java and C++. Major project-2015 NIT Raipur
  • 7. Types of design pattern There are many design patterns but all can be categorized into three groups 1. Creational design pattern 2. Structural design pattern 3. Behavioral design pattern Major project-2015 NIT Raipur
  • 8. This design pattern provides the best possible way to create and instantiate an object. It provides a more flexible way to create an object and nature of object can change with nature of program. Three main types of creational design patterns are: 1.1. Singleton Design Pattern 1.2. Factory Method 1.3. Abstract Factory Method Major project-2015 NIT Raipur
  • 9. 1.1 Singleton Pattern Singleton is a class that can be instantiated only once. Hence only a single instance of this class can be created. It can be used at the places where we want to restrict creation of multiple instances of a class. Major project-2015 NIT Raipur
  • 10. Singleton pattern: Implementation 1 This implementation contains server client application in which server is using singleton class. So client can request only one a single instance of server. Major project-2015 NIT Raipur
  • 11. (i) (ii) (i) (ii) (iii) Major project-2015 NIT Raipur
  • 12. 1.2 Factory Method A factory class instantiates and returns a particular type of object based on the data passed to the factory. A factory is a class that is used to encapsulate creation code of object. Major project-2015 NIT Raipur
  • 13. Factory Method: Implementation 2 This implementation contains a simple calculator that is developed using factory pattern. When we pass data for a particular operator then factory returns object for that operator. That object is used for calling methods for that operator Major project-2015 NIT Raipur
  • 14. Binary Operation . Unary operation Major project-2015 NIT Raipur
  • 15. 1.3 Abstract Factory Method This factory is also known as factory of factories. In abstract factory an interface is responsible for creating factory of related object without specifying their classes. Major project-2015 NIT Raipur
  • 16. Abstract Factory: Implementation 3 This implementation consist of a small application in which choosing an animal displays its family and details about that animal. Family is basically the factory returned by abstract factory method. Major project-2015 NIT Raipur
  • 18. Structural Patterns describe how objects and classes can be combined to form larger structures. In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities. Types of structural design patterns are: 2.1 Adapter pattern 2.2 Decorator pattern 2.3 Bridge pattern 2.4 Façade pattern Major project-2015 NIT Raipur
  • 19. 2.1 Adapter Pattern Adapter pattern works as a bridge between two incompatible interfaces. This pattern combines the capability of two independent interfaces. Major project-2015 NIT Raipur
  • 20. Adapter Pattern: Implementation 4 In this implementation we have made a media player which can play both .wav and .mp3 songs. We are using an adapter class for combining features of two types of songs. Major project-2015 NIT Raipur
  • 21. wav song mp3 song Major project-2015 NIT Raipur
  • 22. 2.2 Decorator Pattern Decorator pattern allows a user to add new functionality to an existing object without altering its structure. This pattern creates a decorator class which wraps the original class and provides additional functionality keeping class methods signature intact. Major project-2015 NIT Raipur
  • 23. Decorator Pattern: Implementation 5 Here we have created an applet for depicting decorator pattern. In this application clicking on buttons add extra description to an existing description about an animal. Major project-2015 NIT Raipur
  • 25. 2.3 Bridge method This pattern involves an interface which acts as a bridge which makes the functionality of concrete classes independent from interface implementer classes. It decouples an abstraction from its implementation so that the two can vary independently Major project-2015 NIT Raipur
  • 26. Bridge method: Implementation 6 This implementation contains colored shapes and a bridge is maintained between color and shapes classes. With the help of this bridge it is possible to match names with colored shapes. Major project-2015 NIT Raipur
  • 28. 2.4 Façade Pattern Façade is a face of the building. It hides the complexities of the system and provides an interface to the client from where the client can access the system. Major project-2015 NIT Raipur
  • 29. Façade pattern: Implementation 7 This implementation contains an applet which calculate 2nd , 4th , 6th, 8th , and 9th root of a number. It uses façade pattern to combine square root and cube root methods for calculating other roots. Major project-2015 NIT Raipur
  • 31. 3. Behavioral design pattern Major project-2015 NIT Raipur Behavioral design pattern provides a way to communicate between objects , so it provides flexibility for communication between objects by either creating loose-coupling or hiding implementation detail to reduce communication complexity.
  • 32. 3.1 Template Pattern In Template pattern, an abstract class exposes defined way(s)/template(s) to execute its methods. Its subclasses can override the method implementation as per need but the invocation is to be in the same way as defined by an abstract class. Major project-2015 NIT Raipur
  • 33. Template Pattern: Implementation 8 This is a simple implementation in which template for hockey and cricket are created and order of execution of events are same in both. Order of events are initialize the game, enjoy the game and finish the game. Major project-2015 NIT Raipur
  • 35. 3.2Chain Responsibility Design Pattern Major project-2015 NIT Raipur It gives opportunities to the objects to handle request. Each object handle specific request. For example:-Handling different numbers by positive handler , negative handler and zero handler.
  • 36. Chain : Implementation 9 Positive handler to handle positive numbers Major project-2015 NIT Raipur
  • 37. Handle negative number by handler Major project-2015 NIT Raipur
  • 38. 3.3 Mediator Design Pattern Major project-2015 NIT Raipur Communication between two objects become more complex because of internal structure of objects, so mediator Used to create loose- coupling between objects. For example application for communication between two users:
  • 39. Mediator: Implementation 10 Application for communication between two objects Major project-2015 NIT Raipur
  • 40. 3.4 Strategy Design Pattern Major project-2015 NIT Raipur Handle multiple algorithms with in a class or change execution at run time. For example file compressor application: This application used to compress file in GIP or GZIP or RAR so it has class to handle multiple algorithms and change execution at run time.
  • 41. Strategy pattern : Implementation 11 file compressor Major project-2015 NIT Raipur
  • 42. 3.5 Iterator Design Pattern Major project-2015 NIT Raipur Iterator design pattern is used to access data from large collection of data. Accessing data without exposing it’s internal data structure. For example accessing a channel from collection of channel
  • 43. Iterator: Implementation 12 Application of iterator design pattern Major project-2015 NIT Raipur
  • 44. 3.6 Interpreter design pattern Major project-2015 NIT Raipur This design pattern assign a value in place of complex expression or grammar. Like infix or postfix expression evaluated and assign a specific value. This pattern map a domain to a language, the language to a grammar , a grammar to a object.
  • 45. Interpreter pattern: Implementation 13 Application of interpreter design pattern: A parser from roman to english digit Major project-2015 NIT Raipur
  • 46. 3.7 Observer design pattern Major project-2015 NIT Raipur Observer design pattern is used to hold one-to- many relationship between objects. In this relation if one state change it will notify to another observers. For example suppose three observers to observe Hexadecimal , octal , binary numbers:
  • 47. Observer Pattern: Implementation 14 Application of observer design pattern Major project-2015 NIT Raipur
  • 49. Purpose of tutorial This tutorial has been prepared for the developers to provide best solutions to certain problems faced during software development and for un-experienced developers to learn software design in an easy and faster way. Major project-2015 NIT Raipur
  • 50. Advantage of design pattern: 1.They are reusable in multiple projects. 2.They provide the solutions that help to define the system architecture. 3.They capture the software engineering experiences. 4.They provide transparency to the design of an application. 5.They are well-proved and testified solutions since they have been built upon the knowledge and experience of expert software developers. Major project-2015 NIT Raipur
  • 51. Disadvantages of design pattern: 1. Complex in nature 2. Not always decrease understandability of design or code. They can decrease understandability 3. Picking the correct design pattern and understanding how to implement that pattern to our scenario is difficult. Major project-2015 NIT Raipur
  • 52. Thank you !! Major project-2015 NIT Raipur