Tuesday, March 17, 2015

Design Pattern

Design Pattern:

Design pattern in well defined industry standard approach to solve recurring common software problems. It promotes re-usability 
that leads to more robust, highly maintainable code and it leads to faster development and easy understanding of the code.


Creation Patterns: These design patterns provides way to create objects while hiding the creation logic, rather than instantiating 
       objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case.

Structural Patterns: These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces 
      and define ways to compose objects to obtain new functionalities.
      
Behaviour Patterns: These design patterns are specifically concerned with communication between objects.


behavioural design patterns:
 1. State Design Pattern.
 2. Observer Design pattern - Android Ex: Broadcast receiver
 3. Iterator Pattern - Ex: Java collection framework
 4. Mediator Design Pattern- chat & user list.


structural design pattern:
 1. Adapter design pattern - Android Ex: BaseAdapter, ListAdapter, ArrayAdapter
 2. Proxy Design pattern- Android Ex: ActivityManager, LocationManager and all service manager classes from system process.
 3. Facade Pattern - Ex: MediaPlayer, ContentProvider is kind of Facade Pattern.
 4. Bridge Pattern - decouple an abstraction from its implementation so that the two can vary independently Ex (color & shape abstraction)
 5. Composite Design Pattern - ex: ViewGroup
 6. Decorator Pattern - http://stackoverflow.com/questions/6366385/decorator-pattern-for-io
 7. Flyweight Pattern - String pool 


Creation Design pattern
 1. Factory Pattern - Android Ex: Intent is kind of Factory Pattern
 2. Abstract Factory Design Pattern
 3. Singleton Design Pattern - All system services are singleton classes ActivityManager, Context, LocationManager, TelephonyManager etc...
 4. Builder pattern - Android Ex: Notification.Builder, AlertDialog.Builder
 5. Prototype Pattern - Android Ex: Notification (provides method clone)

Examples of Design Patterns in Java's core libraries

Reference: JournalDev

0 comments:

Post a Comment