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 - Marcus Moore

Part 1

To find the difference between creational, structural, and behavioral patterns, one must define what these are first-hand. By a simple glance, one could say that these patterns in coding are very loose templates for creating something that a designer needs. In a general example, you could say "An -insert pattern- allows us to -insert result-. By using the same -insert pattern- method also lets us to -insert similar result except in another piece of code-." That is, however, a very very loose and unspecific definition of the three.

Getting more into specifics, the names of the patterns represent themselves very well. Creational patterns deal with the creation of classes. It manipulates the 'blue-print' so to speak. Structural patterns deal with the form, or position, or responsibilities. Lastly, behavioral patterns are more focused on how classes and objects get things done or how they communicate.

There are numerous examples that represent these definitions, which are narrowed down to a few particular ones. First taking the creational patterns, we have Abstract Factory, Factory Method, and Singleton. The Abstract Factory stays true to its name in that it acts like a factory to create a 'family' of instances. For example, you might have a game that creates several continents of animals which, at the base, have similar traits of interaction. The Factory Method allows subclasses to instantiate objects. Lastly the Singleton restricts instances to only one creation.

Observing the structural pattern, one can get good examples that depict the name pretty well. Three examples include Composite, Fašade, and Proxy. Under Composite, objects are placed into a tree structure, treating them uniformly to represent heirarchies. Notice it does not deal with creation which is a responsibility of Creational patterns, but it remains tucked nicely under the form and positional aspect of Structural patterns. Fašade allows a uniform interface for various subsystems. Again, this falls under form and perhaps responsibility, as it dictates the form of all the subsystems. Lastly a Proxy is an object that is a placeholder for another object, in a sense. Again, this goes under the positional aspect of Structural patters, as it serves as a 'position' holder.

Lastly is behavioral patterns. Chain of Responsibility is a good example in that it goes through a structure and allows each part of the structure to respond to a request. Another simple example is Observer, which allows notification to objects as to what other objects have changed and respond accordingly. These differ from Creational patterns and Structural patterns in that they look at how objects are acting, and not their structure or how they are created.

http://www.dofactory.com/Patterns/Patterns.aspx#list

Part 2

There is one pattern of interest that I have already discussed and that is the Observer pattern. This pattern seems to allow other objects to see what has happened to a primary objects. It's basically saying "Oh, this just happened with me! Respond accordingly, okay?" It's interesting because it seems like this one is hard to avoid when programming a decently sized interactive program. A mere button could be considered to have an observer, because whatever is interal is waiting for a change in state in the button. Once the button is pushed, the other objects respond as such: "Oh! The button has been pushed. We have been signaled! Start the process!" -As horns blare-

More seriously, I could have a website selling wares of some sort, and there is a status as to what limited items have been purchased. When someone purchases something, it's dependency(perhaps some program on my side which bleeps on my screen) informs me that a purchase has been made and I can ship off whatever they bought. A far off example, but it's definitely something within my mental scope.

http://www.dofactory.com/Patterns/PatternObserver.aspx

Link to this Page