Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 2 - Alex Groleau
Creational patterns deal completely with object creation for organization relative to a particular task or situation. These patterns are useful for determining when an object should be created and why it needs to be created. An example is a singleton pattern in which one class is instantiated and remains alive with no other instantiations.
Structural patterns deal with the organization and relationship between objects. The arrows from class diagrams indicate structural patterns through relationship.
Behavioral patterns include all of the communication between objects directly or indirectly. This would include event listening, observing code to observer objects within a program, general commands sent to objects for actions, and much more. Message sending and therefore behavioral patterns are key to a language like smalltalk.
The singleton design pattern is extremely useful for creating a class with one or few instatiations. This makes sense when you need an object to coordinate specific actions accross a system where having multiple instances of the object floating around would just not make sense. This pattern interests me the most because I coded a few of these in Java for CS2335. A singeton was extremely useful for creating a Java class that would interface with a MySQL database. All other classes could access this singleton directly to get to the database instead of having to instatiate a new MySQL database class object, which does not make sense when you only need one accross the entire application. This approach is efficient and ensured that one class had all of the appropriate information for performing database interaction.
Link to this Page