• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design Patterns Questions

 
Ray Ye
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think the answers to the following questions and why? Thanks,

Your next project requires the development of a system that supports multiple XML Data Type Descriptions (DTDs) (i.e., multiple XML format standards) for passing a specific set of information (in XML format) to a requesting system.
Referring to the above scenario, which one of the following Creational Patterns achieves these requirements without hard coding the creation process for each format type (i.e., each DTD)?
Choice 1 Factory Method
Choice 2 Abstract Factory
Choice 3 Prototype
Choice 4 Singleton
Choice 5 Builder

Your next project requires the development of a subsystem that converts sections of an XML document into HTML. While the input XML documents contain logically equivalent elements, they are based on (i.e., defined by) different DTDs.
Referring to the scenario above, which one of the following creational patterns provides a solution for this task?
Choice 1 Prototype
Choice 2 Visitor
Choice 3 Builder
Choice 4 Singleton
Choice 5 Abstract Factory
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ray,

Your next project requires the development of a system that supports multiple XML Data Type Descriptions (DTDs) (i.e., multiple XML format standards) for passing a specific set of information (in XML format) to a requesting system.
Referring to the above scenario, which one of the following Creational Patterns achieves these requirements without hard coding the creation process for each format type (i.e., each DTD)?
Choice 1 Factory Method
Choice 2 Abstract Factory
Choice 3 Prototype
Choice 4 Singleton
Choice 5 Builder


In this case, i would use the Builder Pattern. The builder pattern is described as "Seperate the construction of a complex object from its representation so that the same construction process can create different representations." in the GoF book. The complex object is your Object data. The representations are its DTDs.

Your next project requires the development of a subsystem that converts sections of an XML document into HTML. While the input XML documents contain logically equivalent elements, they are based on (i.e., defined by) different DTDs.
Referring to the scenario above, which one of the following creational patterns provides a solution for this task?
Choice 1 Prototype
Choice 2 Visitor
Choice 3 Builder
Choice 4 Singleton
Choice 5 Abstract Factory


I can think of 3 ways to do this.
1. XML -> Object -> HTML
2. XML -> XSLT -> HTML
3. XML -> Custom -> HTML

If you never need the object representation of the XML data, you can go with the second or third approaches.

1. XML -> Object : Command Pattern and Object -> HTML: Visitor or Command
2. Well, you would write different XSL documents and voila. This case is not relevant for the given answers.
3. You can use an AbstractFactory pattern to convert different DTDs into the same HTML. Different concrete implementations can handle different DTDs.

Any one else on this?
Dushy
[ June 04, 2004: Message edited by: Dushy Inguva ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic