View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 2 - Daniel King

Part 1:

What are the differences between creational, structural, and behavioral patterns?

Creational patterns handle the creation of objects. They control the creation to prevent complexity in the program. Implementations of this pattern are responsible for instantiating the object with the correct parameters and doing whatever else is required to set up the object. An example of a creational pattern is a factory. Factories are often used to handle the creation of several related objects. The factory creates the specified object and returns it for use elsewhere.

Structural patterns combine objects and their functionalities for a new purpose. They define relationships between multiple objects. An example is the adapter pattern, which provides a consistant interface for several related object. Though these objects may be different in implementation, the interface allows them to be used in the same ways.

Behavioral patterns handle communications between objects. It ties common communication methods together with patterns. This increases flexibility, since one pattern could be useful for several different objects. An example is the iterator pattern. Iterators allow the traversing of a list of objects, while hiding the internal implementation of the list. This allows a standard set of commands to be performed on several types of lists.

References:
Wikipedia - Design Pattern
http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29
Using Design Patterns in UML
http://www.developer.com/design/article.php/3309461


Part 2:

An interesting creational pattern is lazy initialization. This pattern uses a factory to instantiate an object only when it is required. By not creating an object until it is needed can help save memory and processing time. After an object is created it is stored so that it can be accessed again later without having to reinstantiate.

I am interested in this pattern because it can prevent the waste of memory by storing objects which are not yet needed. It could also be useful if the pattern were extended to remove the object from memory after it is no longer required. Also, intense processes can be postponed until they are really required. It is an interesting alternative to loading everything at once.

One possible use of lazy initialization is the loading of pictures. Since loading many pictures at the same time would require much memory, it is more efficient to simply load the picture when it is first shown. It would also be practical for virtual environments. Only objects that have been within the view need to be loaded. Other objects can be loaded as they come into view.

References:
Wikipedia - Lazy Initialization
http://en.wikipedia.org/wiki/Lazy_initialization_pattern

Link to this Page