Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Nirav Shah
Part 1 - What are the differences between creational, structural, and behavioral patterns?
There are three main kinds of design patterns in object oriented programming: creational, structural, and behavioral patterns.
The first design pattern is the creational design pattern. Creational design patterns deal mainly with object creation. Because an inefficient design of object instantiation can create major problems and make simple problems into larger, more complex situations, creational patterns handle object creation in order to solve problems before they unfold. Examples of creational patterns include the Factory pattern, Abstract Factory pattern, Singleton pattern, Prototype pattern, and the Builder pattern.
The second design pattern is the structural design pattern. Unlike creational design patterns, structural patterns do not manage objects instantiation. Instead, they deal mainly with the issue of how to combine different classes and objects into a larger structure in order to get new functionality. Structural patterns many times use inheritance and interfaces to get this new functionality. Examples of structural patterns include the Adapter pattern, Bridge pattern, Composite pattern, Decorator pattern, and the Façade pattern.
The last design pattern is the behavioral design pattern. Unlike the creational design pattern, the behavioral design pattern does not deal primarily with object instantiation. Instead, it handles interaction between various objects, as it deals with communication between different objects. Unlike the structural pattern, which uses different objects to combine into a larger structure, the behavioral pattern utilizes algorithms and assigns responsibilities to assorted objects. Examples of behavioral design patterns include the Mediator pattern, Command pattern, Interpreter pattern, Iterator pattern, Chain of Responsibility pattern, Memento pattern, and the Observer pattern.
Part 2 – Describe an Interesting Pattern
One design pattern that I find interesting is the Singleton design pattern. The Singleton pattern is a type of Creational design pattern. It involves having a “superclass” that is instantiated only once in a programs lifetime and that is usually accessed globally (either by passing it on or through some kind of global class).
I find this design pattern interesting because I find it a very efficient way to manage a program. For example, if you are making a video game, you can have a “game server” or “game engine” class that manages every aspect of the game, from the server, to backend stuff, and even the graphics. This class would have accessors to all of these different functions of the game, making it easier to update/run the game. For example, if say you are playing a multi-player game, and one of the players moves left, the game engine can send that information to all of the clients (players), which will in turn update the graphics on every player’s machine. This pattern makes perfect sense to me, as I have used it before. I used it in my Java programming class (2335) to manage the game I made for my final project, as I had a gameServer class running the entire game. Because of this, I think that the Singleton design pattern would work best in applications that utilize servers with multiple threads, as doing so would allow the most efficient way to manage all of these threads.
Link to this Page