View this PageEdit this Page (locked)Attachments 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 - Oh Kil Kwon

Part 1


Creational patterns are concerned with creating new classes and objects, therefore it abstracts instantiace process. This means its main foucus is dealing with the best way to create class/object. For example, Singleton pattern is an example of creational pattern. The singlenton pattern is used when only one instance of an object is needed throughout the lifetime of an application. The singleton class is instantiated at the time of first access and the same instance is used until the application quits.

Structural patterns are concerned with how groups of classes and objects are composed to form larger structures. This can be done by using inheritance to compose classes/objects.

Behavioral patterns describe not just patterns of objects or classes but also the patterns of communication
between them. These patterns characterize complex control flow that's difficult to follow at run-time. They shift your focus away from flow of control to let you concentrate just on the way objects are interconnected. Behavioral class patterns use inheritance to distribute behavior between classes. Behavioral object patterns use object composition rather than inheritance.

Part 2

As I have mentioned earlier, Singleton is one of creational pattern. It makes sure that there is only one instance is created throughout the program and provide a global point of access. This is useful when exactly one object is needed to coordinate actions across the system. Sometimes it is generalized to systems that operate more efficiently when only one or a few objects exist. I would really like to share an example of Singleton that I found online.

"The President of the United States is a Singleton. The United States Constitution specifies the means by which a president is elected, limits the term of office, and defines the order of succession. As a result, there can be at most one active president at any given time. Regardless of the personal identity of the active president, the title, "The President of the United States" is a global point of access that identifies the person in the office" [Michael Duell, "Non-software examples of software design patterns", Object Magazine, Jul 97, p54].

The Singlton pattern definitely makes sense to me. I can use it many times in my coding. For example, if I need to keep track of some integers in my program, say something like an incremental counter, then I can create a Singleton class which simply keeps track of the value that is being used in multiple areas of my program. The class needs to be able to increment the value as well as return the current value. For this reason, my counter class behavior would be to have exactly one instance of a class that maintains the integer.

Links to this Page