Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Jimmy M. Espana
For Discussion 2, Part 1, I chose to answer the question: What are the differences between creational, structural, and behavioral patterns? I obtained my source, the information to answer this question, from the following URL: http://scholar.google.com/scholar?hl=en&lr=&q=cache:4vns9_l8JZ8J:ugweb.cs.ualberta.ca/~c301/lectures/05-4up.pdf+creational,+structural,+and+behavioral+design+patterns
In order to discuss the differences between creational, structural, and behavioral patterns, we must first understand what design patterns are. Design patterns are proven, practical solutions to common problems in Computer Science. A design pattern is "not as well defined as an algorithm", but it is a "coherent, recognizable" abstraction of "good, reusable design elements". Design patterns are similar to frameworks, but they are more abstract and are "smaller architectural elements" than frameworks. There are many different types of design patterns; creational, structural, and behavioral patterns are types of design patterns. The creational pattern deals with creating objects. Creational design patterns can abstract the "object instantiation process, and make a system independent" of the way its objects are created, composed, and represented. An example of a creational pattern is the factory method design pattern. The factory method pattern defines an interface for creating an object, but allows subclasses to decide which class to instantiate, and "lets a class defer instantiation to subclasses". The structural pattern deals with composing classes. Structural design patterns can "reduce the coupling between two or more classes", introduce an abstract class to "enable future extensions", and encapsulate complex structures. An example of a structural pattern is the adapter design pattern. The adapter pattern converts the "interface of a class into another interface that clients expect". The behavioral pattern deals with distributing "responsibilities among interacting classes". Behavioral design patterns can divide responsibilities between objects, and "characterize complex control flow" that is difficult to follow at runtime. An example of a behavioral pattern is the chain of responsibility design pattern. The chain of responsibility pattern avoids "coupling the sender of a request to its receiver by giving more than one object a chance to handle the request", and chains the receiving objects and passes the "request along the chain until an object handles it".
For Discussion 2, Part 2, I chose to describe the singleton design pattern. I obtained my source, my information, from the following URL: http://en.wikipedia.org/wiki/Singleton_pattern
The singleton design pattern ensures that a class can only have one instance of its self, and provides a global access point to it. This design pattern, the singleton, is normally used to control access to key resources. The problem that the singleton pattern solves is the problem where a programmer wants to limit the application to only one instance of a particular class, but needs global access to that class. The solution that the singleton design pattern uses for this problem, is to make the constructor of the class private and make a static accessor method within that class. What interests me about the singleton design pattern, is its simplicity and importance in programming complex problems. There are many situations in Computer Science, in programming, where there can only be one instance of a class; such as the following example, about a multi-player game, that I will provide. The singleton design pattern makes sense to me because I had to use it in my last semester class, CS2335, where we had to implement a multi-player, online casino with at least three casino games; we, my team members and I, had to make sure there was one and only one instance of each casino game, so that multiple players could play against each other in the same game. I can see myself using the singleton design pattern again, but probable not in this course, since we are programming in Squeak, Smalltalk, which doesn't have access types that are private or static.
Return to the Jimmy M. Espana's CS 2340 Homepage Fall 2005 Who Who's Page.
Links to this Page