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

William Lee - Discussion 2

1. According to The Smalltalk Companion, design patterns are “recurring solutions to design problems you see over and over.” This does not mean they are readymade classes or sets of objects. Rather, a pattern is a piece of information that captures the essence of a solution to a frequently encountered problem and gives a programmer an idea of how to appropriately structure his or her design to resolve the issue in his or her unique context (similar to the way different types of architecture are used to construct each unique, individual building). Such design patterns can be grouped into various categories, including creational, structural, and behavioral patterns.

Creational patterns address issues arising from creating objects and provide some measure of control over this process. Structural patterns focus on the relationships between different classes and provide guidance for assembling larger and more efficient organization of these classes. Behavioral patterns deal with how objects communicate, and they allow programmers to define and control the flow of communication between various classes.

2. One interesting example of a design pattern is the Singleton, a type of creational pattern that allows only one instantiation of a specified object at one time. If an instance of the object does not exist, one is created. Otherwise, references to the single instance of the object are returned for use during program execution. I found this pattern interesting since I had always viewed most classes as blueprints with the ability create anywhere from one to many object instances (almost like the metal plates in a print shop), and I’ve had this mindset ever since cs1322. Thus, the concept of a class purposely designed to enforce only a single instantiation of itself at any one time was a bit of a surprise. I encountered the Singleton for the first time in cs2335 last semester while working on the final project, an online casino, and I can see how I might use it in the future if I have a class that manages a single, program-wide resource (perhaps a fixed, central reservoir of fuel, money, etc. in a simulation program).

Sources:

http://www.dofactory.com/Patterns/Patterns.aspx
http://en.wikipedia.org/wiki/Singleton_pattern
http://starchild.gsfc.nasa.gov/xanadu/xspec/xspec12/design/designPatterns/designpatterns.html
http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29
http://www.cmcrossroads.com/bradapp/docs/patterns-intro.html
http://www.developer.com/design/article.php/3325211

Link to this Page