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 - Manabu Shimobe

(Discussion2)

Part(1)... What are the differences between creational, structural, and behavioral patterns?

The authors of the book titled "Design Patterns: Elements of Reusable Software" divided 23 design patterns into
three types: creational, structural, and behavioral.

(Creational Pattern)
This design pattern is all about class instantiation and deals with the best way to create instances of objects.
This pattern automatically creates objects for you even if you don't instantiate objects directly.
For example, in java, you usually create an instances of an object by using 'new' operator.

Student bob = new Student();

This means that you are simply hard coding how you create the object within your program. However, sometimes abstracting the creation of objects into a special "object creator" class can give your program more flexibility in deciding which objects need to be created for a given case.
Finally, this pattern can be further divided into five types:AbstractFactory Pattern,Builder Pattern,FactoryMethod Pattern,Prototype Pattern,and Singleton Pattern.
(Summary of these patterns can be found at http://c2.com/cgi-bin/wiki?CategoryCreationalPatterns)

(Behavioral Pattern)
Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. It also helps us define the patterns of communication between objects and classes.
Behavioral patterns usually involve only single classes or a single family of classes.
This pattern can be further divided into twelve types according to the Design Patterns book. Among these twelve patterns, the most commonly used are State, Command, Strategy, and Iterator Patterns.
(Summary of these patterns can be found at http://c2.com/cgi-bin/wiki?CategoryBehavioralPatterns)

(Structural Pattern)
Structural Patterns are concerned about how groups of classes are composed to form larger structures.
It helps us change some aspects of system structure independently of other aspects.
(Structural Patterns based on class use inheritance to compose interfaces or implementations.
Structural Patterns that target objects use object composition to obtain new functionality.)
In addition, this pattern also helps us make a system more robust to a paticular kind of structural change.
Among Structural Patterns, the most commonly used are adapter, bridge, composite, facade,and proxy patterns.
(Summary of these patterns can be found at http://c2.com/cgi-bin/wiki?CategoryStructuralPatterns)

Ref...http://www.developer.com/design/article.php/10925_3325211_1
http://c2.com/cgi-bin/wiki?DesignPatterns
http://www.patterndepot.com/put/8/Structural.html


Part 2 - Describe an Interesting Pattern

Singleton is one of the most commonly used patterns.
Singleton ensures that there is always only one instance of a class and we can access the object throughout the program. So, Singleton seems similar to a global variable in a sense. However, although a global variable makes an object accessible throughout a program, it doesn’t prevent you from instantiating more than one objects of a class. Singleton does prevent a programmer from creating more than one objects of a class because the class (singleton pattern) only creates an object of itself when it doesn't already exist. (NOTE...In java, a constructor should be private or make a constructor protected and put a singleton class in a special package so that the class can not be instantiated by other class files.)

Singleton Pattern is interesting because it is very simple and clearly makes sense since we sometimes only need exactly one instance of a class. For example, I used singleton for a class to manage all players' data when I was working on the online casino project in cs2335 because I only needed one instance of data management class so that all other parts of the system can access the same data whenever they need. Furthermore, I will also use Singleton Pattern if I'm required to write a Connection Manager class to manage communications between the multi-client and the server program. (since I only need one instance of a Connection Manager class and want to acccess the instance throughout the system)

Ref...http://c2.com/cgi-bin/wiki?SingletonPattern
http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html

Link to this Page