.code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; max-height: 200px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; } .code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; }

Wednesday, March 25, 2020

Software Design Patterns



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


No comments:

Post a Comment

SPRING MVC SIMPLE CRUD APPLICATION