Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise 1 Review Exercise 3 Preview David Rabinowitz.

Similar presentations


Presentation on theme: "Exercise 1 Review Exercise 3 Preview David Rabinowitz."— Presentation transcript:

1 Exercise 1 Review Exercise 3 Preview David Rabinowitz

2 March 3rd, 2004 Object Oriented Design Course 2 Exercise 1 File system walker Prints a given file system in XML format Should be open to future enhancements Some requirements where given Our goals Practice in design Use of learned patterns Develop using today’s tools – IDE, UML and unit tests

3 March 3rd, 2004 Object Oriented Design Course 3 Primary question Do we create the xml directly, or do we need keep some model in memory The first is much simpler The second is more flexible

4 March 3rd, 2004 Object Oriented Design Course 4 Building XML directly Module for reading the file system An XMLPrinter / XMLBuilder for directly creating the XML Manipulations are done on the XML. Hard to extend it to other uses

5 March 3rd, 2004 Object Oriented Design Course 5 Creating File Hierarchy Abstract File Directory is a Composite Common behavior is implemented at the top

6 March 3rd, 2004 Object Oriented Design Course 6 Concrete File Hierarchy Actual file Mime type relies on the context: return getContext().getMimeType( getName())

7 March 3rd, 2004 Object Oriented Design Course 7 Other Actors Visitor for hierarchy traversing AbstractVisitor with empty implemntations Context for common tasks

8 March 3rd, 2004 Object Oriented Design Course 8 Parsing The File System A general engine Receives a general input FileSystemInput is a concrete class New input format means another class, not another hierarchy! Receives a Builder Why not Abstract Factory?

9 March 3rd, 2004 Object Oriented Design Course 9 Printing Visitor for traversing the hierarchy Decorating it with DirectoryOnlyVisitor How to solve the accept(this) problem? Get printable properties: Keeping it inside the visitor Other visitor (non recursive) who has getFileProperties() method Decorator on it

10 March 3rd, 2004 Object Oriented Design Course 10 Future Requirements (I) Other output formats Another visitor Decorating the current one and use XSLT Other file types Enrich the hierarchy Output modifications Decorate the visitor for modification Decorate the iterator for sorting

11 March 3rd, 2004 Object Oriented Design Course 11 Future Requirements (II) New Input format New input format parser Adding icon Flyweight

12 March 3rd, 2004 Object Oriented Design Course 12 Mock Objects How to test components not written yet ? Test the visitor using programmatically built file system Test the builder using MockFileSystem (no need to read actual file system) Rely on interfaces!

13 March 3rd, 2004 Object Oriented Design Course 13 Summary Think big Think practical Don’t create unnecessary levels ImageFile CompositeFile Rely on interfaces Test from the beginning MockObjects


Download ppt "Exercise 1 Review Exercise 3 Preview David Rabinowitz."

Similar presentations


Ads by Google