Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Arwa Tyebkhan
What are the differences between creational, structural, and behavioral patterns?
As defined by Janusz Zalewski, patterns can be defined as "a solution to a problem in a context". Gamma et(1) describes the function of design patterns to be the naming, abstraction, and identification of the key aspects of a common design structure that make it useful for creating a reusable object-oriented design. As I understand it, design patters identify the classes of a system and their respective objects, their purposes within the system, and how these classes are related to others.
According to Gamma et, all dsign patterns are categorized into one of the following three patterns:
Creational patterns are concerned with the optimal instantiaction of classes taking the situation into consideration. It takes into accout how the instance objects will be used, and thus makes for optimal creation.
Examples of creational design petterns are: Singleton, Abstract Factory, Builder, Prototype.
Structural patterns are concerned with the structure/ composition of the objects created. They describe how classes and objects can be put together to form larger structures. Use of this pattern enables a system to be more flexible, and more reobust to any structurwal change that may be neccesary.
There are 7 structural patterns including the Adapter Pattern, Bridge Pattern, Composite Pattern, and Proxy Pattern.
Behavioral patterns are concerned with the behavior of the objects - how they relate to other ojects and how they interract with one another. They deal with the communication between all objects. It is concerned with bettering algorithms, and assigning various responsibilities betwee4n objects, so as to optimize the communication.
Examples of behavioral patterns are: Observer Pattern, Mediator, Iterator, Strategy, and State pattern etc.
(1)GAMMA E. et al., Design Patterns: Elements of Reusable Software Design, Addison-Wesley,
Reading, Mass., 1995.
Part 2 - Describe an Interesting Pattern
The iterator, one of the simplest and most widely used design pattern, is used to “provide a way to access the elements of an aggregate object sequentially and without exposing its underlying representation.”(1)
This design pattern falls under the behavioral design pattern category. To me, it is a design that enables users/ clients to access the “concrete aggregate”, without really having to understand or deal with the underlying traversal that takes place, and that is performed by the Iterator. An aggregate is a list or collection of objects.
The client can access this using the method CreateIterator() [in java], and the simple methods in the Iterator’s interface need to be defined – first(), next(), isDone() and currentItem().
The simplicity that this design pattern adds to programming with a collection of data, and its ease of use interests me. This pattern is most definitely extremely useful during coding, and I can see how it makes coding large aggregates a lot simpler. The programmers do not have to concern themselves with how the traversals take place through the aggregate object. It hides from the client the underlying piping, leaving them only having to worry about the functionality for each object. The traversal interface is thus separated from the aggregate itself, thus leading to a much simpler aggregate interface.
In addition to this, as stated by (2) you can also define special iterators, that can perform processing according to the programmers need. This adds flexibility and usability to the pattern. Also, as iterators are interfaces, they can be implemented according to the users needs.
(1)Gamma, E., R. Helm, R. Johnson, J. Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley Longman, Inc., Reading.
Links to this Page
- Arwa Tyebkhan last edited on 7 December 2005 at 5:43 pm by r66h119.res.gatech.edu
- Fall 2005 Discussion 2 last edited on 3 October 2005 at 4:29 pm by adsl-068-209-116-021.sip.asm.bellsouth.net