Individual Assignment 2: Design Patterns

567 Words2 Pages

When researching about design patterns in programming you instantly realize that they can be very useful in implementing a certain piece of code or just having it as a useful programming practice. Design patterns are created to solve common programming problems that keep on recurring in a certain context when designing a program. There are several types of design patterns that are all split into several groups. Some of these groups are Algorithm Strategy Patterns, Execution Patterns, Structural design patterns, Creational design patterns, Behavioral design patterns and Computational design patterns. Each of these sub groups of design patterns goes about solving a different type of problem. Design patterns can be beneficial because of the simple fact that they are solving programming problems that would usually surface when programming.
The type of design pattern that I chose to further research falls under the Creational design pattern group. Creational Patterns are meant to solve problems that deals with object creation instruments, which means to create objects in a way that is appropriate for the specific circumstance.
I have chosen to research the Singleton design pattern more in depth. The Singleton design pattern addresses the problem of sometimes only needing to have one instance for a specific class. The intent is to ensure that only one instance of the class in made and to provide a global point of access. Although this design pattern is one of the simplest that exist, it really can have a huge impact. The pattern involves only a single class (hence the very creative name) which is responsible to instantiate itself to insure that it will not be instantiated again. An example of this design pattern is when we are workin...

... middle of paper ...

...hould only be instantiated once and having another instantiation would lead to a lot of bugs and errors. If we use the singleton design pattern we are able to still globally access the User Manager and retrieve information such as user ID’s or be able to sign a user up as needed. But with the Singleton pattern we won’t need to worry about re instantiation, because it’s just not possible.

Works Cited:
Bloch, Joshua. Effective Java. Upper Saddle River, NJ: Addison-Wesley, 2011. Print.
Gamma, Erich. Design Patterns: Elements of Reusable Object-oriented Software. Reading, MA: Addison-Wesley, 1995. Print.
Horstmann, Cay S., and Gary Cornell. "Example of Singleton Design Pattern in Java." Singleton Design Pattern in Java. Concretepage.com, 01 Dec. 2013. Web. 01 May 2014.
"Singleton Design Pattern." Wikipedia. Wikimedia Foundation, 9 Oct. 2013. Web. 01 May 2014.

Open Document