Builder A Creational Design Pattern - PowerPoint PPT Presentation

About This Presentation
Title:

Builder A Creational Design Pattern

Description:

Separates the construction of a complex object from its representation ... be independent of the parts that make up the object and how they're assembled ... – PowerPoint PPT presentation

Number of Views:790
Avg rating:3.0/5.0
Slides: 13
Provided by: alexb57
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Builder A Creational Design Pattern


1
BuilderA Creational Design Pattern
  • A Presentation by Alex Bluhm
  • And

2
What are Creational Design Patterns?
3
Creational Design Patterns
  • Abstract instantiation process
  • Flexibility in whats created, who creates it,
    how its created and when
  • Patterns
  • Abstract Factory
  • Builder
  • Factory Method
  • Prototype
  • Singleton

4
Builder Design Pattern
  • Separates the construction of a complex object
    from its representation
  • Same construction process can create different
    representations
  • Bob says

Builders specify abstract interfaces for creating
parts of a Product object
5
Participants in Builder Pattern
  • Builder
  • ConcreteBuilder
  • Director
  • Product
  • Builder
  • ConcreteBuilder
  • Director
  • Product

6
Structure for Participants
Client
Product
7
Builder Pattern Interaction
8
When to use a Builder Pattern
  • When the algorithm for building a complex object
    should be independent of the parts that make up
    the object and how theyre assembled
  • When the construction process must allow
    different representations for the object thats
    constructed
  • When building a composite structural object

9
Key Consequence of Builder Pattern
  • Vary a products internal representation
  • Isolates code for construction and representation

Dont forget that the Builder Design Pattern also
gives you finer control over the construction
process!
10
How to code a builder
  • Assembly and Construction Interface
  • No abstract class for products
  • Empty methods as default in Builder

Class MazeBuilder Public virtual void
BuildMaze() virtual void BuildRoom(int
room) virtual void BuildDoor(int
roomFrom, int roomTo) virtual Maze
GetMaze() return 0 Protected
MazeBuilder()
11
Other Creational Patterns
  • Object Creation
  • Abstract Factory
  • Prototype
  • Singleton
  • Class Creation
  • Factory Method

12
Special Thanks
  • Design Patterns. Elements of Reusable
    Object-Oriented Software
  • Erich Gamma, Richard Helm, Ralph Johnson, John
    Vlissides
  • Provider of Design Pattern powerpoint slides
    online. (http//vik.ktu.lt/moduliai/)
  • Bob the Builder
Write a Comment
User Comments (0)
About PowerShow.com