Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Stephen Rollyson
Part I: Answer One Question.
What are the differences between creational, structural, and behavioral patterns?
Creational design patterns lay out object creation strategies, structural design patterns are strategies for implementing relationships between classes, and behavioral patterns are strategies that describe how classes and objects communicate with each other.
Part II: Describe an Interesting Pattern.
I chose the factory method design pattern to describe. This design pattern features two classes, the creator and the product. Within the creator class is a method which will return an object of the product class. This is an incredibly simple design pattern that is often, if not nearly always, used in object-oriented languages. In fact, I believe Java's java.awt.Color class uses this design pattern for simplicity reasons. Rather than explicitly creating a new Color object, the Color class acts as a factory method creator class for itself and you can simply call a method (e.g. Color.blue()), which will create a product of one of the most commonly used Color objects for the programmer.
I think this design pattern is a very effective and understandable way of separating an object from its creation method and I can see myself using it to shorten the amount of code I write if I frequently create similarly-valued objects.
Link to this Page