Design Pattern
“Each pattern describe a problem which occurs over and over again in our environment, and then describe the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice”
[Christopher Alexander]
Design Pattern Space
There are two criteria of design patterns namely Purpose and the Scope.
Purpose - What pattern does
Mainly there are 23 design patterns which categories under three main categories. Those are Creational , Structural, and Behavioral patterns.
- Creational – Process of Object creation
- Structural – Composition of Classes or Objects
- Behavioral – Classes or Objects interact and distribute responsibility
Scope - Whether the pattern applied primarily to a class or an object
- Class – Deals with relationships between classes and sub-classes (Via inheritance and static)
- Object – Deals with object relationships (can be changed at runtime and dynamic)
Advantages of Design Patterns
- Can reusable in multiple projects.
- They capture the software engineering experience.
- They provide transparency to the design of an application
- They are well-proved and testified solutions since they have been built upon the knowledge and experience of expert software developers
- These do not guarantee an absolute solutions.
Singleton Design Patterns
Singleton design pattern is one of the simplest design pattern and this categories under creational design pattern. this class have a single class which create only one object.
Examples for singleton are
- Clip Board
- Windows Registry
Step 1 - Create a Singleton class
SingleObject.java
Step 2 - Get the only object from the singleton class
SingletonPatternDemo.java
Step 3 - Verify the Output
Written by - Pramodi Samaratunga
Madhusanka Edirimanna
Undergraduates - University of Moratuwa



