SlideShare a Scribd company logo
Prototype Design
Pattern
Overview
1. Brief Last Week
2. Intent
3. Implement in JavaScript
4. Problem & Solve
5. Benefits
6. Consequences
7. When
8. Rule of Thumb
Brief Last Week
1. Builder Pattern
2. Finalise what is presentations
Intent
1. Specifying the kind of objects to create using a
prototypical instance
2. Creating new objects by copying its prototype
Implement in JavaScript
Diagram
Implement in JavaScript
Participants
The objects participating in this pattern are:
• Client -- In sample code: the run() function.
creates a new object by asking a prototype to clone itself
• Prototype -- In sample code: CustomerPrototype
creates an interfaces to clone itself
• Clones -- In sample code: Customer
the cloned objects that are being created
6
Problem & Solve
1. Avoid subclasses of an object creator
2. Avoid in the inherent cost of creating a new
object in the standard way
Benefits
1. It eliminates the (potentially expensive)
overhead of initialising an object
2. It simplifies and can optimise the use case
where multiple objects of the same type will
have mostly the same data
Consequences
• You can add and remove classes at runtime by
cloning them as needed.
• You can revise the internal data representation of
a class at runtime based on program conditions.
• You can also specify new objects at runtime
without creating a proliferation of classes and
inheritance structures.
When
• Use the Prototype pattern when a system should be independent
of how its products are created, composed, and represented.
• When the classes to instantiate are specified at run-time, for
example, by dynamic loading
• To avoid building a class hierarchy of factories that parallels the
class hierarchy of products; or
• When instances of a class can have one of only a few different
combinations of state. It may be more convenient to install a
corresponding number of prototypes and clone them rather than
instantiating the class manually, each time with the appropriate
state.
Rule of Thumbs
• Sometimes creational patterns are competitors:
there are cases when either Prototype or Abstract
Factory could be used properly. At other times
they are complementory: Abstract Factory might
store a set of Prototypes from which to clone and
return product objects. Abstract Factory, Builder,
and Prototype can use Singleton in their
implementations.
Rule of Thumbs
• Abstract Factory classes are often implemented
with Factory Methods, but they can be
implemented using Prototype.
Rule of Thumbs
• Factory Method: creation through inheritance.
Protoype: creation through delegation.
Rule of Thumbs
• Often, designs start out using Factory Method
(less complicated, more customizable,
subclasses proliferate) and evolve toward
Abstract Factory, Protoype, or Builder (more
flexible, more complex) as the designer discovers
where more flexibility is needed.
Rule of Thumbs
• Prototype doesn't require subclassing, but it does
require an "initialize" operation. Factory Method
requires subclassing, but doesn't require Initialize.
Rule of Thumbs
• Designs that make heavy use of the Composite
and Decorator patterns often can benefit from
Prototype as well.
Rule of Thumbs
• Prototype co-opts one instance of a class for use
as a breeder of all future instances.
Rule of Thumbs
• Prototypes are useful when object initialization is
expensive, and you anticipate few variations on
the initialization parameters. In this context,
Prototype can avoid expensive "creation from
scratch", and support cheap cloning of a pre-
initialized prototype.
Rule of Thumbs
• Prototype is unique among the other creational
patterns in that it doesn't require a class – only an
object. Object-oriented languages like Self and
Omega that do away with classes completely rely
on prototypes for creating new objects.

More Related Content

What's hot

Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Creational pattern
Creational patternCreational pattern
Creational pattern
Himanshu
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
Jyaasa Technologies
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
Sanae BEKKAR
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
paramisoft
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
Anjan Kumar Bollam
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
Mudasir Qazi
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Anuja Arosha
 
Design pattern
Design patternDesign pattern
Design pattern
Thibaut De Broca
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
Shakil Ahmed
 
Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design Pattern
Adeel Riaz
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
Shakil Ahmed
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
MUHAMMAD FARHAN ASLAM
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
11prasoon
 
Facade pattern
Facade patternFacade pattern
Facade pattern
JAINIK PATEL
 
Builder design pattern
Builder design patternBuilder design pattern
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
Amit Kabra
 

What's hot (20)

Design patterns
Design patternsDesign patterns
Design patterns
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design pattern
Design patternDesign pattern
Design pattern
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design Pattern
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Builder design pattern
Builder design patternBuilder design pattern
Builder design pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 

Viewers also liked

Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder
paramisoft
 
Design Patterns and Usage
Design Patterns and UsageDesign Patterns and Usage
Design Patterns and Usage
Mindfire Solutions
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
Rapid Prototyping With jQuery
Rapid Prototyping With jQueryRapid Prototyping With jQuery
Rapid Prototyping With jQuery
Paul Bakaus
 
1 rapid prototyping model
1 rapid prototyping model1 rapid prototyping model
1 rapid prototyping modeldelaco
 
Rapid Prototyping,Rapid prototype,SLA prototype
Rapid Prototyping,Rapid prototype,SLA prototypeRapid Prototyping,Rapid prototype,SLA prototype
Rapid Prototyping,Rapid prototype,SLA prototype
Coco
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
Rapid prototyping seminar
Rapid prototyping seminarRapid prototyping seminar
Rapid prototyping seminar
avwhysoserious
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
Rapid prototyping
Rapid prototypingRapid prototyping
Rapid prototyping
Wael_helal
 
Prototype model
Prototype modelPrototype model
Prototype modelshuisharma
 

Viewers also liked (12)

Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder
 
Design Patterns and Usage
Design Patterns and UsageDesign Patterns and Usage
Design Patterns and Usage
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Rapid Prototyping With jQuery
Rapid Prototyping With jQueryRapid Prototyping With jQuery
Rapid Prototyping With jQuery
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
1 rapid prototyping model
1 rapid prototyping model1 rapid prototyping model
1 rapid prototyping model
 
Rapid Prototyping,Rapid prototype,SLA prototype
Rapid Prototyping,Rapid prototype,SLA prototypeRapid Prototyping,Rapid prototype,SLA prototype
Rapid Prototyping,Rapid prototype,SLA prototype
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
 
Rapid prototyping seminar
Rapid prototyping seminarRapid prototyping seminar
Rapid prototyping seminar
 
Javascript
JavascriptJavascript
Javascript
 
Rapid prototyping
Rapid prototypingRapid prototyping
Rapid prototyping
 
Prototype model
Prototype modelPrototype model
Prototype model
 

Similar to Prototype design patterns

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
Sachin Patidar
 
Effective java
Effective javaEffective java
Effective java
Emprovise
 
Creational Patterns
Creational PatternsCreational Patterns
Creational Patterns
Asma CHERIF
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
Amr Abd El Latief
 
Creating and destroying objects
Creating and destroying objectsCreating and destroying objects
Creating and destroying objects
Sandeep Chawla
 
Layers of Smalltalk Application
Layers of Smalltalk ApplicationLayers of Smalltalk Application
Layers of Smalltalk Applicationspeludner
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
C Meenakshi Meyyappan
 
Desing Patterns Summary - by Jim Fawcett
Desing Patterns Summary - by Jim FawcettDesing Patterns Summary - by Jim Fawcett
Desing Patterns Summary - by Jim Fawcett
Dareen Alhiyari
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
Pham Huy Tung
 
Sda 8
Sda   8Sda   8
31 days Refactoring
31 days Refactoring31 days Refactoring
31 days Refactoring
Ahasanul Kalam Akib
 
Design patterns
Design patternsDesign patterns
Design patternsAlok Guha
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etc
Yaron Karni
 
Introduction to design_patterns
Introduction to design_patternsIntroduction to design_patterns
Introduction to design_patterns
amitarcade
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
Talentica Software
 
Style & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design PatternsStyle & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design Patterns
Nick Pruehs
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
Nguyen Trung Kien
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
Ayush Sharma
 
Racing car katas Ⅲ - Static Cling
Racing car katas Ⅲ - Static ClingRacing car katas Ⅲ - Static Cling
Racing car katas Ⅲ - Static Cling
Georg Berky
 

Similar to Prototype design patterns (20)

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
Effective java
Effective javaEffective java
Effective java
 
Creational Patterns
Creational PatternsCreational Patterns
Creational Patterns
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Creating and destroying objects
Creating and destroying objectsCreating and destroying objects
Creating and destroying objects
 
Layers of Smalltalk Application
Layers of Smalltalk ApplicationLayers of Smalltalk Application
Layers of Smalltalk Application
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
 
Desing Patterns Summary - by Jim Fawcett
Desing Patterns Summary - by Jim FawcettDesing Patterns Summary - by Jim Fawcett
Desing Patterns Summary - by Jim Fawcett
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
 
Sda 8
Sda   8Sda   8
Sda 8
 
31 days Refactoring
31 days Refactoring31 days Refactoring
31 days Refactoring
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Junit, mockito, etc
Junit, mockito, etcJunit, mockito, etc
Junit, mockito, etc
 
Introduction to design_patterns
Introduction to design_patternsIntroduction to design_patterns
Introduction to design_patterns
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
 
Style & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design PatternsStyle & Design Principles 02 - Design Patterns
Style & Design Principles 02 - Design Patterns
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Racing car katas Ⅲ - Static Cling
Racing car katas Ⅲ - Static ClingRacing car katas Ⅲ - Static Cling
Racing car katas Ⅲ - Static Cling
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

Prototype design patterns

  • 2. Overview 1. Brief Last Week 2. Intent 3. Implement in JavaScript 4. Problem & Solve 5. Benefits 6. Consequences 7. When 8. Rule of Thumb
  • 3. Brief Last Week 1. Builder Pattern 2. Finalise what is presentations
  • 4. Intent 1. Specifying the kind of objects to create using a prototypical instance 2. Creating new objects by copying its prototype
  • 6. Implement in JavaScript Participants The objects participating in this pattern are: • Client -- In sample code: the run() function. creates a new object by asking a prototype to clone itself • Prototype -- In sample code: CustomerPrototype creates an interfaces to clone itself • Clones -- In sample code: Customer the cloned objects that are being created 6
  • 7.
  • 8. Problem & Solve 1. Avoid subclasses of an object creator 2. Avoid in the inherent cost of creating a new object in the standard way
  • 9. Benefits 1. It eliminates the (potentially expensive) overhead of initialising an object 2. It simplifies and can optimise the use case where multiple objects of the same type will have mostly the same data
  • 10. Consequences • You can add and remove classes at runtime by cloning them as needed. • You can revise the internal data representation of a class at runtime based on program conditions. • You can also specify new objects at runtime without creating a proliferation of classes and inheritance structures.
  • 11. When • Use the Prototype pattern when a system should be independent of how its products are created, composed, and represented. • When the classes to instantiate are specified at run-time, for example, by dynamic loading • To avoid building a class hierarchy of factories that parallels the class hierarchy of products; or • When instances of a class can have one of only a few different combinations of state. It may be more convenient to install a corresponding number of prototypes and clone them rather than instantiating the class manually, each time with the appropriate state.
  • 12. Rule of Thumbs • Sometimes creational patterns are competitors: there are cases when either Prototype or Abstract Factory could be used properly. At other times they are complementory: Abstract Factory might store a set of Prototypes from which to clone and return product objects. Abstract Factory, Builder, and Prototype can use Singleton in their implementations.
  • 13. Rule of Thumbs • Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype.
  • 14. Rule of Thumbs • Factory Method: creation through inheritance. Protoype: creation through delegation.
  • 15. Rule of Thumbs • Often, designs start out using Factory Method (less complicated, more customizable, subclasses proliferate) and evolve toward Abstract Factory, Protoype, or Builder (more flexible, more complex) as the designer discovers where more flexibility is needed.
  • 16. Rule of Thumbs • Prototype doesn't require subclassing, but it does require an "initialize" operation. Factory Method requires subclassing, but doesn't require Initialize.
  • 17. Rule of Thumbs • Designs that make heavy use of the Composite and Decorator patterns often can benefit from Prototype as well.
  • 18. Rule of Thumbs • Prototype co-opts one instance of a class for use as a breeder of all future instances.
  • 19. Rule of Thumbs • Prototypes are useful when object initialization is expensive, and you anticipate few variations on the initialization parameters. In this context, Prototype can avoid expensive "creation from scratch", and support cheap cloning of a pre- initialized prototype.
  • 20. Rule of Thumbs • Prototype is unique among the other creational patterns in that it doesn't require a class – only an object. Object-oriented languages like Self and Omega that do away with classes completely rely on prototypes for creating new objects.

Editor's Notes

  1. talk about builder pattern finalise our thoughts on the pattern what is presentations move to behind
  2. one which creates objects based on a template of an existing object through cloning
  3. “It hides the concrete product classes from the client, thereby reducing the number of names clients know about. Moreover, these patterns let a client work with application-specific classes without modification.”
  4. hit database