AlexLecture_BuilderPattern

AlexLecture_BuilderPattern - Recall: Abstract Factory...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Builder Pattern 2 Recall: Abstract Factory Pattern ± The factory only makes parts. ± The factory does not maintain any state information. I don’t remember which parts you have asked me to make. ± But, sometimes it is desirable for the factory to remember state. This factory is thus called a Builder. For example, a cityBuilder. It remembers what elements you have put into a city, based on which the cityBuilder design roads to connect all elements. ± The client does not need to care about the details. For example, the client just call cityBuilder.addPeople(10,000); cityBuilder.addPostalOffice(2); cityBuilder.addStore(3); cityBuilder.getCity(); ± Borrow ideas from the abstract factory pattern, we can have a variety of cityBuilders! 3 Exercise ± You want to develop a tool that can convert a RTF (Rich Text Format) document to several other formats, such as plain ASCII text, Latex text, text widget, etc. ± Design classes for this application 4 Problem ± Should you write a converter program for each format? ± If you do so, all the converter programs share the same code for reading the RTF file (reading tokens, etc). ± How to refactor all the common code into one class whose function is only reading source RTF documents?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 5 Better Solution 6 Builder Pattern - UML 7 Participants ± Builder (TextConverter) specifies an abstract interface for creating parts of a Product object.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2009 for the course CSE 335 taught by Professor Kraemer during the Fall '08 term at Michigan State University.

Page1 / 5

AlexLecture_BuilderPattern - Recall: Abstract Factory...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online