Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
3rd year CM major.
Go back to: Fall 2005 Who's Who
Discussion 3-Marcus Moore
Discussion 4 - Marcus Moore
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.
Links to this Page