11
Builder A Creational Design Pattern Dorit Goldman Oded Sapir Based on Alex Bluhm Rensselaer Polytechnic Institute Troy, New-York

Builder Presentation

  • Upload
    bar

  • View
    218

  • Download
    2

Embed Size (px)

DESCRIPTION

מצגת בנושא תבנית עיצוב builder

Citation preview

  • BuilderA Creational Design PatternDorit GoldmanOded Sapir

    Based on Alex BluhmRensselaer Polytechnic Institute Troy, New-York

  • Patterns:Abstract FactoryBuilderFactory MethodPrototypeSingleton

  • Builder Design Pattern :

    -Builder

  • Participants in Builder PatternBuilderConcreteBuilderDirectorProductBuilderConcreteBuilderDirectorProduct

  • Structure for ParticipantsProductClient

  • Builder Pattern Interaction

  • When to use a Builder PatternWhen the algorithm for building a complex object should be independent of the parts that make up the object and how theyre assembledWhen the construction process must allow different representations for the object thats constructedWhen building a composite structural object

  • Key Consequence of Builder PatternVary a products internal representationIsolates code for construction and representation

    Dont forget that the Builder Design Pattern also gives you finer control over the construction process!

  • How to code a builderAssembly and Construction InterfaceNo abstract class for productsEmpty 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();};

  • Other Creational PatternsObject CreationAbstract FactoryPrototypeSingletonClass CreationFactory Method

  • Special ThanksDesign Patterns. Elements of Reusable Object-Oriented SoftwareErich Gamma, Richard Helm, Ralph Johnson, John VlissidesProvider of Design Pattern powerpoint slides online. (http://vik.ktu.lt/moduliai/)Bob the Builder