Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Cooper Welch
Question 1: What are the differences between creational, structural, and behavioral patterns?
Creational patterns are involved with how object instantiation takes place. For instance, a creational pattern might allow a program to create objects when necessary, rather than having the programmer instantiate them all directly. Creational patterns can be broken down into two sub-categories: class-creational patterns and object-creational patterns. Class-creational patterns rely on inheritance to get the job done, whereas object-creational patterns use delegation.
Structural patterns concern themselves with how to strategically group and combine classes and objects so as to facilitate the effective creation of large architectures. For instance, a structural pattern might be most useful when planning a complex user interface or large database system.
Behavioral patterns provide useful means of dealing with how objects communicate with one another. In other words, behavioral patterns can help the programmer define object communication and flow control in a complex program.
Question 2: Describe one design pattern or pattern language in your own words. Again, reference your sources. Explain what interests you about this pattern. Does it make sense to you? Can you see using it in your coding? If so, what for? If not, why not?
The Singleton design pattern is wicked cool. It’s incredibly useful for creating simple, yet effective program structures. Often times when I’m writing a program, I’ll write and instantiate unnecessary amounts of the same class, when in fact, only one instance of the class needs to exist at any given time. By using the Singleton design pattern in my coding, I can solve this problem with ease. According to Wikipedia, “The singleton pattern is implemented by creating a class with a method that creates a new instance of the object if one does not exist. If one does exist it returns a reference to the object that already exists. To make sure that the object cannot be instantiated any other way the constructor is made either private or protected.” In other words, by allowing the class to instantiate itself, only a “single” instance of the class exists in the program at any given time. Additionally, the rest of the program has global access to this class. Thus, any part of the program can access the Singleton class, and only one instance of the Singleton class ever needs to exist. Ultimately, the Singleton design pattern seriously reduces the amount of code that needs to be written, thus making for a less cluttered and effective program.
Link to this Page