Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 by Elizabeth Solomon
What are the differences between creational, structural, and behavioral patterns?
M. L. Liu
The writer makes us aware that there are a total of 23 design patterns categorized into creational, structural and behavioral patterns.
Creational patterns allows the programmer to find the best way to create instances of objects. The creational patterns include: Factory Pattern, Abstract Factory Pattern, Builder Pattern, Prototype Pattern and Singleton Pattern. This pattern is noted as important because once program should not depend on how objects are created and arranged.
James Watson describes each of the Creational Patterns as follows:
The Factory Pattern is used to choose and return an instance of a class from a number of similar classes based on data you provide to the factory.
The Abstract Factory Pattern is used to return one of several groups of classes. In some cases it actually returns a Factory for that group of classes.
The Builder Pattern assembles a number of objects to make a new object, based on the data with which it is presented. Frequently, the choice of which way the objects are assembled is achieved using a Factory.
The Prototype Pattern copies or clones an existing class rather than creating a new instance when creating new instances is more expensive.
The Singleton Pattern is a pattern that insures there is one and only one instance of an object, and that it is possible to obtain global access to that one instance.
Structural Patterns describe how classes and objects can be combined to form larger structures. Examples of this pattern are: Adapter pattern, Bridge pattern, Composite pattern, Decorator pattern, Façade pattern, Flyweight pattern and Proxy pattern.
James Watson describes each of the Structural Patterns as follows:
The Adapter pattern, used to change the interface of one class to that of another one.
The Bridge pattern, intended to keep the interface to your client program constant while allowing you to change the actual kind of class you display or use. You can then change the interface and the underlying class separately.
The Composite pattern, a collection of objects, any one of which may be either itself a Composite, or just a primitive object.
The Decorator pattern, a class that surrounds a given class, adds new capabilities to it, and passes all the unchanged methods to the underlying class.
The Façade pattern, which groups a complex object hierarchy and provides a new, simpler interface to access those data.
The Flyweight pattern, which provides a way to limit the proliferation of small, similar class instances by moving some of the class data outside the class and passing it in during various execution methods.
The Proxy pattern, which provides a simple place-holder class for a more complex class which is expensive to instantiate.
Behavioral Patterns are patterns that are specifically deal with communication between objects. Patterns that are considered behavioral are: Observer, Mediator, Chain of Responsibility, Template, Interpreter, Strategy, Visitor, State and Command Patterns.
James Watson describes each of the Behavioral Patterns as follows:
The Observer pattern defines the way a number of classes can be notified of a change,
The Mediator defines how communication between classes can be simplified by using another class to keep all classes from having to know about each other.
The Chain of Responsibility allows an even further decoupling between classes, by passing a request between classes until it is recognized.
The Template pattern provides an abstract definition of an algorithm, and
The Interpreter provides a definition of how to include language elements in a program.
The Strategy pattern encapsulates an algorithm inside a class,
The Visitor pattern adds function to a class,
The State pattern provides a memory for a class’s instance variables.
The Command pattern provides a simple way to separate execution of a command from the interface environment that produced it. 
Exploring the Singleton Design Pattern
The Singleton Design Pattern ensures only one instance of a class and allows global access to it.
- Describe one design pattern or pattern language in your own words.
What problem does this solve, or put another way, what is our motivation to use it?
- Explain what interests you about this pattern.
There is a need to have an area from which to globally access and maintain some type of data in most applications. There are also cases in object-oriented systems where there should be only one class, or a predefined number of instances of a class, running at any given time. Mark describes a good example as follows: when a class is being used to maintain an incremental counter, the simple counter class needs to keep track of an integer value that is being used in multiple areas of an application. The class needs to be able to increment this counter as well as return the current value. For this situation, the desired class behavior would be to have exactly one instance of a class that maintains the integer and nothing more.
At first glance, one might be tempted to create an instance of a counter class as a just a static global variable. This is a common technique but really only solves part of the problem; it solves the problem of global accessibility, but does nothing to ensure that there is only one instance of the class running at any given time. The responsibility of having only one instance of the class should fall on the class itself and not on the user of the class. The users of the class should always be free from having to monitor and control the number of running instances of the class. This makes perfect sense. one has to ensure that only one instance is running so the right update is passed to the necessary variables.
- Does it make sense to you?
What is needed is a way to control how class instances are created and then ensure that only one gets created at any given time. This would give us exactly the behavior we require and free a client from having to know any class details.
I do see myself using it in my code because i need to keep track of the original state of the font if they add more words and remove it later. The user shouldn't have to do that.Singleton pattern provides an area from which to globally access and maintain some the font of the power point slide.
- Can you see using it in your coding? If so, what for? If not, why not?
About the Portland Form by Ward Cunningham, firstname.lastname@example.org
The Portland Form is comparable to the human language. Similar patterns are grouped together cohesively.
Just as words of similar connectivity are grouped together to ultimately form a language. The patterns will act as the words and the portland form generated will be the language which is understood from combining these words. The language effectively describes a scenario. Ward believes all patterns will be linked together someday.It is narrative unlike other template forms used by Peter Coad.
As the paper describes, each pattern in the Portland Form makes a statement of the form: "such and so forces create this or that problem, therefore, build a thing-a-ma-jig to deal with them." The pattern takes its name from the thing-a-ma-jig, the solution. Comparing that to language this is a typical cause and response scenario. "such and so forces" form the subject, "create" forms the verb and "this or that problem" forms the object of the cause. Which is exactly the pattern of language, likewise the response.
The writer further explains that: "Each pattern in the Portland Form also places itself and the forces that create it within the context of other forces, both stronger and weaker, and the solutions they require. A wise designer resolves the stronger forces first, then goes on to address weaker ones. Patterns capture this ordering by citing stronger and weaker patterns in opening and closing paragraphs. The total paragraph structure ends up looking like:
Having done so and so you now face this problem...
Here is why the problem exists and what forces must be resolved...
Make something along the following lines. I'll give you the help I can...
Now you are ready to move on to one of the following problems..."
Just like any paragraph the consequence of the response is explained and a probable combat for the response given.
 The Design Pattern Java Companion Copyright (C) 1998, by James W. Cooper
IBM Thomas J. Watson Research Center
Link to this Page
- Elizabeth Solomon last edited on 9 December 2005 at 3:56 pm by quinhagak-win.cc.gatech.edu