<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Design Patterns</title>
	<atom:link href="http://designpattern.freetimelabs.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://designpattern.freetimelabs.com</link>
	<description>Explore the Art of Technical design</description>
	<lastBuildDate>Wed, 19 May 2010 09:53:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Observer Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=40</link>
		<comments>http://designpattern.freetimelabs.com/?p=40#comments</comments>
		<pubDate>Mon, 20 Apr 2009 12:17:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=40</guid>
		<description><![CDATA[This pattern will notify change to various classes.
]]></description>
			<content:encoded><![CDATA[<p>This pattern will notify change to various classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Singleton Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=35</link>
		<comments>http://designpattern.freetimelabs.com/?p=35#comments</comments>
		<pubDate>Mon, 20 Apr 2009 09:49:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=35</guid>
		<description><![CDATA[Need to create only one object and make sure no other object will create again the object of same class but it can share the same object  created once.
A Singleton Pattern ensures a class has only one object or instance and provides a global point of access to it.
A singleton is a class that can [...]]]></description>
			<content:encoded><![CDATA[<p>Need to create only one object and make sure no other object will create again the object of same class but it can share the same object  created once.</p>
<p>A Singleton Pattern ensures a class has only one object or instance and provides a global point of access to it.</p>
<p>A singleton is a class that can be instantiated <strong>only one time in a JVM per class loader</strong>. Repeated calls always return the same instance. Ensures that a class has only one instance, and provide a global point of access. It can be an issue if singleton class gets loaded by multiple class loaders.</p>
<pre class="brush:java">/*
*
*  lazy creation of the object
*  ensure only one object
*
*  Chance of creating multiple
*  objects in multi threads environment.
*
*/

public class Singleton
{

	private static Singleton singleton;

	private Singleton(){
		System.out.println( "Create an object " +
		"which is having the private Constructor" );
	}

	public static Singleton getInstance(){
		if(singleton == null){
			singleton = new Singleton();
		}
		return singleton;
	}

}</pre>
<pre class="brush:java">/*
*
*  lazy creation of the object
*  ensure only one object in conditions
*  of multiple threading environment
*
*  Every time you call a method
*  it is locks up to give you the object
*  synchronized block is expensive
*
*/
class SingletonSync
{

	private static SingletonSync singleton;

	private SingletonSync(){
		System.out.println( "Create an object " +
				"which is having the private" );
	}

	public static synchronized SingletonSync getInstance(){
		if(singleton == null){
			singleton = new SingletonSync();
		}
		return singleton;
	}

}</pre>
<pre class="brush:java">
<pre class="brush:java">/**
 *  This method of creation of the object is defining and initializing the object
 *
 *  ensure only one object in conditions of multiple threading environment without
 *  using the synchronized block
 *
 *  you will find an object weather it is used or not
 *  So it will occupy memory etc.
 *
 */
class SingletonEager {

	private static SingletonEager
		single = new SingletonEager();

	private SingletonEager(){
		System.out.println( "Create an object " +
				"which is having the private" );
	}

	public static SingletonEager getInstance(){
		return single;
	}

}</pre>
<pre class="brush:java">/**
 * I think this is the most preferable
 *  way of implementing the singleton pattern
 *
 *  lazy creation of the object
 *  ensure only one object in conditions
 *  of multiple threading environment
 *  only one time synchronization block is used.
 *
 *  synchronized block is expensive
 *
 */

class SingletonDoubleCheck {

	// The volatile keyword ensures that multiple threads
	// handle the unique instance variable correctly
	// when it is being initialized to the singleton instance
	private volatile static SingletonDoubleCheck singleton;

	private SingletonDoubleCheck(){
		System.out.println( "Create an object" +
				" with double checked syncronized" );
	}

    // we only synchronize one time when it cont found the object
	public static SingletonDoubleCheck getInstance(){
		if(singleton == null){
			synchronized (SingletonDoubleCheck.class) {
				singleton = new SingletonDoubleCheck();
			}
		}
		return singleton;
	}
}</pre>
</pre>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">/**</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*  This method of creation of the object is defining and initializing the object</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*  ensure only one object in conditions of multiple threading environment without</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*  using the synchronized block</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*  you will find an object weather it is used or not</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*  So it will occupy memory etc.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">*/</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class SingletonEager {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private static SingletonEager</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>single = new SingletonEager();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>private SingletonEager(){</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println( &#8220;Create an object &#8221; +</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>&#8220;which is having the private&#8221; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static SingletonEager getInstance(){</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>return single;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1136px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=35</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Builder Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=30</link>
		<comments>http://designpattern.freetimelabs.com/?p=30#comments</comments>
		<pubDate>Mon, 20 Apr 2009 09:41:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=30</guid>
		<description><![CDATA[
The builder pattern encapsulate or separate the construction of a complex object from its representation so that the same construction process can create different representations.
]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<p>The builder pattern encapsulate or separate the construction of a complex object from its representation so that the same construction process can create different representations.</p></div>
<div id="attachment_31" class="wp-caption alignnone" style="width: 434px"><a href="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/builder-pattern.gif"><img class="size-full wp-image-31" title="builder-pattern" src="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/builder-pattern.gif" alt="The Builder Pattern" width="424" height="179" /></a><p class="wp-caption-text">The Builder Pattern</p></div>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abstract Factory Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=26</link>
		<comments>http://designpattern.freetimelabs.com/?p=26#comments</comments>
		<pubDate>Mon, 20 Apr 2009 09:34:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=26</guid>
		<description><![CDATA[Objects creates the objects of releated classes without specifying the concrete classes.
]]></description>
			<content:encoded><![CDATA[<p>Objects creates the objects of releated classes without specifying the concrete classes.</p>
<div id="attachment_28" class="wp-caption alignnone" style="width: 447px"><a href="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/abstract-factory.gif"><img class="size-full wp-image-28" title="abstract-factory" src="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/abstract-factory.gif" alt="Abstract Factory Pattern" width="437" height="471" /></a><p class="wp-caption-text">Abstract Factory Pattern</p></div>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=26</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abstract Factory Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=19</link>
		<comments>http://designpattern.freetimelabs.com/?p=19#comments</comments>
		<pubDate>Fri, 17 Apr 2009 11:54:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=19</guid>
		<description><![CDATA[Provides an interface for creating families of  related or dependent objects without specifying their concrete classes
]]></description>
			<content:encoded><![CDATA[<p>Provides an interface for creating families of  related or dependent objects without specifying their concrete classes</p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Factory Pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=16</link>
		<comments>http://designpattern.freetimelabs.com/?p=16#comments</comments>
		<pubDate>Fri, 17 Apr 2009 11:13:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=16</guid>
		<description><![CDATA[Object is basically instace of  there prototype called class. There are lot of ways to create the object in various technologies. But ultimately we need to create an object.
What is the strategy of creating objects. weather we use &#8220;new&#8221; key word to create an object or we are using the method to get the created object.
Factory [...]]]></description>
			<content:encoded><![CDATA[<p>Object is basically instace of  there prototype called class. There are lot of ways to create the object in various technologies. But ultimately we need to create an object.</p>
<p>What is the strategy of creating objects. weather we use &#8220;new&#8221; key word to create an object or we are using the method to get the created object.</p>
<p>Factory pattern defines a way and handle creation the objects. It is basically talks about the obtects which are helpful to create the object without knowing the class of the object.Factory pattern encapsulate object creation.</p>
<p>How do we implement Factory pattern?</p>
<p>Accroding to GOF</p>
<p>Define an interface for creating an object but let subclasses decide which class to instanciate. Factory method lets a class difer instantiation to subclass.</p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=16</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creational Patterns</title>
		<link>http://designpattern.freetimelabs.com/?p=13</link>
		<comments>http://designpattern.freetimelabs.com/?p=13#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:46:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Creational Patterns]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=13</guid>
		<description><![CDATA[In object oriented technologies we need to create the objects. But how, what is the process? what is the best way to create an object? Do we create object using or explicitly calling the constructor or we need to use any kind of  patterns used to create the objects. So the object creation patterns help [...]]]></description>
			<content:encoded><![CDATA[<p>In object oriented technologies we need to create the objects. But how, what is the process? what is the best way to create an object? Do we create object using or explicitly calling the constructor or we need to use any kind of  patterns used to create the objects. So the object creation patterns help us to explain the different kind of object creations methodologies and there intent and pros and cons.</p>
<p>So we have popular patterns such as Singleton, Factory, Abstract Factory, Builder, Prototype etc. we will see these and discuss in details in next posts</p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interface and Abstract class pattern</title>
		<link>http://designpattern.freetimelabs.com/?p=5</link>
		<comments>http://designpattern.freetimelabs.com/?p=5#comments</comments>
		<pubDate>Thu, 16 Apr 2009 11:49:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Fundamental Design Pattern]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=5</guid>
		<description><![CDATA[Client classes are independent of the classes that implement the behavior of the class and make sure that there is consistent behavior of the classes which implement the interface.
The abstract class implement the interface and the concrete classes extends the behaviour of the abstract class.
Don&#8217;t  chose only between interface and abstract class. Let abstract class [...]]]></description>
			<content:encoded><![CDATA[<p>Client classes are independent of the classes that implement the behavior of the class and make sure that there is consistent behavior of the classes which implement the interface.</p>
<p>The abstract class implement the interface and the concrete classes extends the behaviour of the abstract class.</p>
<p>Don&#8217;t  chose only between interface and abstract class. Let abstract class implement the interface and the concrete classes extend the abstract class.</p>
<p>Interfaces can be used to hide the specific class that implement the behavior from the client classes</p>
<p>Organize the classes that provide related behavior common the the abstract super class helps to ensure consistency of implementation</p>
<p>Using both interface and abstract class pattern helps the object desing to get the benefit of both the interface and abstract classes.</p>
<p><a href="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/interface-abstract-class-pattern.bmp"><img class="alignnone size-full wp-image-6" title="interface-abstract-class-pattern" src="http://designpattern.freetimelabs.com/wp-content/uploads/2009/04/interface-abstract-class-pattern.bmp" alt="interface-abstract-class-pattern" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design as a thought</title>
		<link>http://designpattern.freetimelabs.com/?p=1</link>
		<comments>http://designpattern.freetimelabs.com/?p=1#comments</comments>
		<pubDate>Wed, 15 Apr 2009 09:21:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design Pattern]]></category>

		<guid isPermaLink="false">http://designpattern.freetimelabs.com/?p=1</guid>
		<description><![CDATA[Design is an ART of designer. Various thoughts are combined to originate a design. When those thoughts of designer are accepted by the community, then it becomes a pattern which is tested and followed and implemented.
We are focused most on the technological design and design pattern applied for architecting the software application. Irrespective of technology [...]]]></description>
			<content:encoded><![CDATA[<p style="line-height: 14.25pt;"><span style="font-size: 10pt; color: black; font-family: &quot;Georgia&quot;,&quot;serif&quot;;">Design is an ART of designer. Various thoughts are combined to originate a design. When those thoughts of designer are accepted by the community, then it becomes a pattern which is tested and followed and implemented.</span></p>
<p style="line-height: 14.25pt;"><span style="font-size: 10pt; color: black; font-family: &quot;Georgia&quot;,&quot;serif&quot;;">We are focused most on the technological design and design pattern applied for architecting the software application. Irrespective of technology we discuss here most importantly the intent, advantages and disadvantages of the design patterns. <span style="mso-spacerun: yes;"> </span>Please join hands with us to contribute to this cause to make this blog helpful for those who really wants to understand the design pattern and apply in there daily life.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://designpattern.freetimelabs.com/?feed=rss2&amp;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
