Content deleted Content added
Normana400 (talk | contribs) |
No edit summary |
||
Line 238:
A less abstract example might be DocumentBuilder with addParagraph, addImage etc methods. Then we could have a PdfDocumentBuilder, WordDocumentBuilder etc implementations. [[Special:Contributions/81.187.215.34|81.187.215.34]] ([[User talk:81.187.215.34|talk]]) 11:23, 10 July 2016 (UTC)
== UML class and sequence diagram ==
I would like to share the following [[Unified Modeling Language|UML]] diagrams I have published on my [http://www.w3sdesign.com Design Patterns Open Online Learning] website. Your comments are welcomed!
[[File:w3sDesign Builder Design Pattern UML.jpg|frame|none|A sample UML class and sequence diagram for the Builder design pattern.]]
In the above [[Unified Modeling Language|UML]] [[Class diagram|class diagram]],
the <code>Director</code> class doesn't instantiate the <code>ProductA1</code> and <code>ProductB1</code> classes directly.
Instead, the <code>Director</code> refers to the <code>Builder</code> interface to create the objects,
which makes the <code>Director</code> independent of which concrete classes are instantiated (which representation of the complex object is created).
The <code>Builder1</code> class implements the <code>Builder</code> interface by creating and assembling the <code>ProductA1</code> and <code>ProductB1</code> objects
<br>
The [[Unified Modeling Language|UML]] [[Sequence diagram|sequence diagram]] shows the run-time interactions:
The <code>Director</code> object calls <code>buildPartA()</code> on the <code>Builder1</code> object, which creates and assembles the <code>ProductA1</code> object.
Thereafter,
the <code>Director</code> calls <code>BuildPartB()</code> on <code>Builder1</code>, which creates and assembles the <code>ProductB1</code> object. <br>
[[User:Vanderjoe|Vanderjoe]] ([[User talk:Vanderjoe|talk]]) 15:42, 5 August 2017 (UTC)
|