Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Monday, October 31, 2011

Factory Design pattern common usage

Common Usage
Along with singleton pattern the factory is one of the most used patterns. Almost any application has some factories. Here are a some examples in java:
- factories providing an xml parser: javax.xml.parsers.DocumentBuilderFactory or javax.xml.parsers.SAXParserFactory
- java.net.URLConnection - allows users to decide which protocol to use

Sunday, October 30, 2011

Factory pattern When to Use

Factory pattern should be used when: - a framework delegate the creation of objects derived from a common superclass to the factory - we need flexibility in adding new types of objects that must be created by the class

Saturday, October 29, 2011

Singleton Design Pattern Common Usage

There are many common situations when singleton pattern is used:
- Logger Classes
- Configuration Classes
- Accesing resources in shared mode
- Other design patterns implemented as Singletons: Factories and Abstract Factories, Builder, Prototype

Friday, October 28, 2011

Factory(Simplified version of Factory Method) Design Pattern

Factory(Simplified version of Factory Method) - Creates objects without exposing the instantiation logic to the client andRefers to the newly created object through a common interface.

Singleton pattern how to use

Singleton pattern should be used when we must ensure that only one instance of a class is created and when the instance must be available through all the code. A special care should be taken in multithreading environments when multible threads must access the same resources throught the same singleton object.

Singleton Design Pattern

Singleton - Ensure that only one instance of a class is createdand Provide a global access point to the object.