ÿþÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Con-Type" con="text/html; charset=utf-8" /> <title>Creational Patterns (GOF)</title> <META name="Description" con="GOF Design patterns"> <META name="keywords" content="Software Design Patterns, Software Architectures "> <META NAME="Distribution" CONTENT="Global"> <META NAME="Rating" CONTENT="General"> <META NAME="robots" content="index, follow"> <META NAME="Subject" CONTENT="meta tags - meta tag generators - search engines"> </head> <body> <a href="http://www.soudamini.net">Soudamini in .net technology</a>&nbsp; <table align="center"> <tr> <td> <script type="text/javascript"><!-- google_ad_client = "pub-1653454597666492"; /* software */ google_ad_slot = "2605119444"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <hr /> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td style="width: 200" valign="top"> </td> <td style="width: 911px" valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td style="width: 911px" valign="top" align="right"> <a href="../Info/Resume.html">About Me</a>&nbsp; <a href="./index.htm">Home</a> &nbsp; <a href="http://www.soudamini.net/sitemap.htm ">SITE MAP</a> &nbsp; &nbsp; <a href="http://www.soudamini.net/search.htm ">SEARCH</a> </td> </tr> </table> <hr /> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td style="width: 200" valign="top"> <br /> <div class="menu" > &nbsp;&nbsp;Resources</div> <div class="menu"> <br /> &nbsp;&nbsp;<a href="../Patterns-Practices/Index.html">Patterns Practices</a>&nbsp;&nbsp; <br /> <br /> &nbsp;&nbsp;<a href="../DotNet/Index.html">DotNet</a>&nbsp;&nbsp; <br /> <br /> &nbsp;&nbsp;<a href="../Database/Index.html">SQL Server</a>&nbsp;&nbsp; <br /> <br /> &nbsp;&nbsp;<a href="../Info/Index.html">Miscellaneous</a>&nbsp;&nbsp; <br /> <br /> <br /> </div> </td> <td> &nbsp;&nbsp;&nbsp;</td> <td style="width: 727px" valign="top"> <br /> <strong><span style="text-decoration: underline">Creational Patterns<br /> <br /> </span></strong>The creational patterns aim to separate a system from how its objects are created, tre by increasing t flexibility of t system.<br /> There are 5 different patterns in this group.&nbsp;<ol> <li>Abstract Factory : Creates an instance of several families of classes </li> <li>Builder : Separates object construction from its representation </li> <li>Factory Method : Creates an instance of several derived classes </li> <li>Prototype : A fully initialized instance to be copied or cloned </li> <li>Singleton A class of which only a single instance can exist </li> </ol> <p> <strong><span style="text-decoration: underline">Abstract Factory Pattern</span></strong></p> <img alt="AbstractFactory" src="AbstractFactory.jpg" /> <p> Abstract factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.So the object families can be interchanged without upsetting t client. So t client in this case knows an abstract product and the abstract factory . The real products are created by t concrete factories. T client in this case is not botred about which factory is creating the concrete products as it knows only the abstract product. The information about t concrete factory is provided by t client.</p> <p> T limitation of Abstract Factory is that , it is not easy to add a new product . If a new product is added, then all the factories and the factory interface need to be updated. Also t client code needs to change to use t new product. So this pattern is not extensible.</p> <p> <span style="text-decoration: underline"><strong>Builder Pattern</strong></span></p> <img alt="Builder" src="Builder.jpg" /> <p> <span>Bulder pattern separates t specification of a complex object from its actual construction. The same construction process can create different representations. T Abstract factory and t Builder patterns are similar. But t Abstract factory concentrates on what product is created, where as the builder concentrates on how t specific product is created. T IBuilder is similar to t IFactory described in the previous section. Here the Director instructs the builder about the steps to build parts. Tn each build t specific parts differently to make different products.</span></p> <p> <strong><span style="text-decoration: underline">Factory Method Pattern</span></strong></p> <img alt="FactoryMethod" src="FactoryMethod.jpg" /> <p> <span>T Factory Pattern is a way of creating objects by letting t subclasses decide which class to instantiate. In this case various subclasses implement an interface. T Factory Method instantiates t particular subclass based on t information provided by client.</span></p> <p> <strong><span style="text-decoration: underline">Prototype Pattern</span></strong></p> <img alt="Prototype" src="Prototype.jpg" /> <p> T Prototype pattern creates new objects by cloning one stored prototype class. It speeds up instantiation of very large classes. in addition we can have a PrototypeManager class to maintain t list of clone types and tir keys. C# provides shallow copy feature by the MemberwiseClone() method. For deep copy either serialization or reflection can be used.</p> <p> <strong><span style="text-decoration: underline">Singleton Pattern</span></strong></p> <img alt="Singleton" src="Singleton.jpg" /> <p> The Singleton Pattern ensures that only one instance of a class exists. In this case t class itself is responsible for creating itself. More over t object is not created until it is really needed. Singleton pattern can be used along with Facade, Abstract Factory. t effectiveness of t Singleton pattern depends on the developer. Sometimes it is not a good idea to make a class Singleton, there by providing a global access to t instance. We may consider to use a quasi Singleton approach. In this case the classes are not singletons but the creation is controlled by anotr class so that each time t same instance is returned. Or we may also consider using a container like Unity.</p> <br /> </td> </tr> </table> </td> </tr> </table> <center> <script type="text/javascript"><!-- google_ad_client = "pub-1653454597666492"; /* software */ google_ad_slot = "2605119444"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <br /> <a href="http://www.rficdesign.com/electronic" title = "Electronics Tutorial" >Electronics</a>&nbsp; <a href="http://www.rficdesign.com/rf-design" title = "RF Design" >rf design</a>&nbsp; <a href="http://www.rficdesign.com/vlsi-design" title = "VLSI Tutorial" >VLSI </a> &nbsp; <a href="http://www.rficdesign.com/free-ieee-papers" title = "Free IEEE papers" >Free IEEE papers</a>&nbsp; <a href=" http://www.rficdesign.com/vlsi-interview-question" title = "vlsi interview questions" >VLSI Interview</a>&nbsp; <a href="http://www.rficdesign.com" title = "rfic design" >RFIC Technologies</a> <a href='http://www.suchitav.com'>RF design</a> <a href="http://www.soudamini.net/index.rss ">RSS</a> &nbsp; &nbsp; <br /> </center> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-18852850-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>