<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

<channel>
	<title>The Corporate Code</title>
	
	<link>http://thecorporatecode.wordpress.com</link>
	<description>Personal findings on my carreer</description>
	<lastBuildDate>Sun, 24 Jun 2007 18:00:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/29a76ee115704265fffdbd657bd7838e?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Corporate Code</title>
		<link>http://thecorporatecode.wordpress.com</link>
	</image>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/TheCorporateCode" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Mac-nified !!</title>
		<link>http://thecorporatecode.wordpress.com/2007/06/24/mac-nified/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/06/24/mac-nified/#comments</comments>
		<pubDate>Sun, 24 Jun 2007 18:00:12 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[computers]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/06/24/mac-nified/</guid>
		<description><![CDATA[I&#8217;ve bought a new laptop last week, a Mac !!
I&#8217;ve had some trouble getting used to it, but once you get used to the keyboard, it&#8217;s alright :)
I&#8217;ve found the most problems with the keyboard during programming, because you need a lot of special characters wich a normal user might not need that often  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=24&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img src="http://thecorporatecode.files.wordpress.com/2007/06/apple-logo.jpg?w=80" alt="apple-logo.jpg" align="left" border="0" hspace="5" vspace="0" width="80" />I&#8217;ve bought a new laptop last week, a Mac !!</p>
<p>I&#8217;ve had some trouble getting used to it, but once you get used to the keyboard, it&#8217;s alright :)<br />
I&#8217;ve found the most problems with the keyboard during programming, because you need a lot of special characters wich a normal user might not need that often  But all&#8217;s good now, and I&#8217;m loving the little machine :)<br />
Below are the specs of the laptop :</p>
<p>Intel 2ghz core 2 duo<br />
2Gb ram<br />
120 Gb harddrive</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=24&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/06/24/mac-nified/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/06/apple-logo.jpg" medium="image">
			<media:title type="html">apple-logo.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Our firewall is a pervert !!</title>
		<link>http://thecorporatecode.wordpress.com/2007/06/08/our-firewall-is-a-pervert/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/06/08/our-firewall-is-a-pervert/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 11:57:18 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[penguins]]></category>
		<category><![CDATA[surfing]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/06/08/our-firewall-is-a-pervert/</guid>
		<description><![CDATA[It&#8217;s been a while, and I&#8217;m pretty busy at the moment, so I don&#8217;t have a lot of time to post that often, but quieter times are ahead, so stay tuned :)
While searching the net for a wallpaper I stumbled upon a funny Access Denied message from our firewall. The funny thing was that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=19&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s been a while, and I&#8217;m pretty busy at the moment, so I don&#8217;t have a lot of time to post that often, but quieter times are ahead, so stay tuned :)</p>
<p>While searching the net for a wallpaper I stumbled upon a funny Access Denied message from our firewall. The funny thing was that I was searching for a wallpaper with a penguin in it and the first result I clicked on Google produced this error message<span id="more-19"></span></p>
<p><a href="http://thecorporatecode.files.wordpress.com/2007/06/access.jpg" title="Access Denied"><img border="0" width="75%" src="http://thecorporatecode.files.wordpress.com/2007/06/access.jpg" alt="Access Denied" /></a><a href="http://thecorporatecode.files.wordpress.com/2007/06/ad.jpg" title="Access Denied"> </a></p>
<p>I don&#8217;t see the link between the categories, but I&#8217;m convinced that our firewall is a pervert ! penguins, Intimate apparel/swimsuit and software downloads shouldn&#8217;t be on one page together : )</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=19&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/06/08/our-firewall-is-a-pervert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/06/access.jpg" medium="image">
			<media:title type="html">Access Denied</media:title>
		</media:content>
	</item>
		<item>
		<title>Decorate your objects !</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/21/decorate-your-objects/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/21/decorate-your-objects/#comments</comments>
		<pubDate>Mon, 21 May 2007 12:06:56 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Decorator]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[gof]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/21/decorate-your-objects/</guid>
		<description><![CDATA[Today I will be discussing the decorator pattern. This pattern is used to add responsibilities to your objects at run-time rather then at compile time. You can find some examples of the decorator pattern by looking at the Java I/O API or the swing table API. Below is a small example of the decorator pattern [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=18&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today I will be discussing the decorator pattern. This pattern is used to add responsibilities to your objects at run-time rather then at compile time. You can find some examples of the decorator pattern by looking at the Java I/O API or the swing table API. Below is a small example of the decorator pattern in action :<br />
<code><br />
LineNumberReader lrdr = new LineNumberReader(new FileReader(filename));<br />
</code><br />
As you can see we wrap the FileReader into the LineNumberReader which adds certain functionalities to the FileReader.<span id="more-18"></span><br />
As always, we start with the UML scheme for this pattern :</p>
<p><a href="http://thecorporatecode.files.wordpress.com/2007/05/decorator_basic.jpg" title="Decorator pattern UML"><img src="http://thecorporatecode.files.wordpress.com/2007/05/decorator_basic.jpg" alt="Decorator pattern UML" border="0" width="75%" /></a></p>
<p>As you can see in the scheme above,  The decorator will hold a reference to the decorated object and delegate it’s methods to the object. In this way we create a chain which will go all the way into the most inner class of the pattern. Below is a use case diagram which shows you how it works :</p>
<p><a href="http://thecorporatecode.files.wordpress.com/2007/05/use_case_decorator.jpg" title="Decorator pattern Use Case"><img src="http://thecorporatecode.files.wordpress.com/2007/05/use_case_decorator.jpg" alt="Decorator pattern Use Case" border="0" width="75%" /></a><br />
Because most of the methods in the decorator just pass the call to the reference object, we can create an abstract class of the decorator which has a default behavior which is to delegate the call to his reference object.<br />
Let’s take a look at a code sample for this pattern. Imagine a Textview widget. We might want the textview to have some nice borders. By implementing this with the decorator pattern, the textview object doesn’t have to be modified in any way, in fact, it doesn’t even have to know anything about the borders to function correctly.<br />
<code><br />
public abstract  class AView {<br />
public abstract void draw();<br />
}<br />
</code></p>
<p>next up, we have an implementation of the Aview  :</p>
<p><code><br />
public class Textview extends AView {<br />
public void draw();<br />
// draw the textview<br />
}<br />
</code><br />
Now we create the decorator, which is an abstract class :<br />
<code><br />
public abstract class BorderDecorator extends AView {<br />
public abstract void draw();<br />
}<br />
</code></p>
<p>And now for the actual Decorators :</p>
<p><code><br />
public class 3Dborder extends BorderDecorator {<br />
private AView component;<br />
public 3Dborder(AView compo) {<br />
This.component = compo;<br />
}<br />
public draw() {<br />
component.draw();<br />
// code to draw the 3D border<br />
}<br />
}<br />
public class BevelBorder extends BorderDecorator {<br />
private AView component;<br />
public 3Dborder(AView compo) {<br />
This.component = compo;<br />
}<br />
public draw() {<br />
component.draw();<br />
// code to draw the bevel border<br />
}<br />
}<br />
</code></p>
<p>And now for the usage :</p>
<p><code><br />
AView tv = new TextView();<br />
Tv = new 3Dborder(tv);<br />
Aview tv2 = new BevelBorder(new TextView());<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=18&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/21/decorate-your-objects/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/05/decorator_basic.jpg" medium="image">
			<media:title type="html">Decorator pattern UML</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/05/use_case_decorator.jpg" medium="image">
			<media:title type="html">Decorator pattern Use Case</media:title>
		</media:content>
	</item>
		<item>
		<title>Mac OSX versus Vista</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/14/mac-osx-versus-vista/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/14/mac-osx-versus-vista/#comments</comments>
		<pubDate>Mon, 14 May 2007 21:57:49 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/14/mac-osx-versus-vista/</guid>
		<description><![CDATA[I&#8217;ve stumbled upon a funny advertisement for Apple, not that I&#8217;m a real apple fan, but is really covers why I don&#8217;t use vista :)
 
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=15&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve stumbled upon a funny advertisement for Apple, not that I&#8217;m a real apple fan, but is really covers why I don&#8217;t use vista :)</p>
<p><span id="more-15"></span> <code><span style="text-align:center; display: block;"><a href="http://thecorporatecode.wordpress.com/2007/05/14/mac-osx-versus-vista/"><img src="http://img.youtube.com/vi/_n4mdcXa8B0/2.jpg" alt="" /></a></span></code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=15&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/14/mac-osx-versus-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/_n4mdcXa8B0/2.jpg" medium="image" />
	</item>
		<item>
		<title>Using the composite pattern</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/14/using-the-composite-pattern/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/14/using-the-composite-pattern/#comments</comments>
		<pubDate>Mon, 14 May 2007 14:39:00 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[composite]]></category>
		<category><![CDATA[gof]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/14/using-the-composite-pattern/</guid>
		<description><![CDATA[Today I&#8217;ve been looking at the composite pattern, in order to use it in the project I&#8217;m currently working on. The composite pattern is mainly designed to create a uniform way to approach similar objects. Let&#8217;s start with a nice quote from the GOF :
Compose objects into tree structures to represent part-whole hierarchies. Composite lets [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=13&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today I&#8217;ve been looking at the composite pattern, in order to use it in the project I&#8217;m currently working on. The composite pattern is mainly designed to create a uniform way to approach similar objects. Let&#8217;s start with a nice quote from the GOF :</p>
<blockquote><p>Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.</p></blockquote>
<p><span id="more-13"></span>What this basically means is that with the composite pattern we can create a tree-like structure of objects where every object can either be a leaf or a composite. This allows us to create a structure with an indefinite depth of objects. Let me just point out that there are 2 different implementations for this pattern but I will discuss both of them so you can decide which want you want to use.</p>
<p>Let&#8217;s start with the UML scheme for this pattern.</p>
<p><a href="http://thecorporatecode.files.wordpress.com/2007/05/composite.jpg" title="composite.jpg"><img src="http://thecorporatecode.files.wordpress.com/2007/05/composite.jpg?w=400" alt="composite.jpg" style="width:400px;height:363px;" align="middle" border="0" width="400" /></a></p>
<p>As you can see in the scheme we start with creating an interface for our composite pattern, which we will use in our client classes. By Using this interface we&#8217;re allowing ourselves to access our objects without actually knowing whether this object is a leaf or a composite in our structure. The basic idea is to add all generic methods to the interface so that you can access them in the client class by using the interface. The composite implementations should delegate all these generic methods to his child objects. This way we can traverse the tree and preform an operation on all components of our tree.</p>
<p>Let&#8217;s have a look at some code now. We will create a component pattern for shape objects. By using the composite pattern we can have drawings which have an infinite number of shapes. First of all we create an interface for our component pattern :</p>
<p><code><br />
public interface Component {<br />
public void draw();<br />
public void growSize(int size);<br />
public boolean isComposite();<br />
}<br />
</code><br />
As you can see we created an interface for our component pattern which defines the methods that apply to all components in our structure. Our next step would be to create the implementations of this interface, we&#8217;ll start with the leaf :<br />
<code><br />
public class Circle Component {</code><code>public void draw() {<br />
// actual implementation of our draw<br />
}<br />
public void growSize(int size) {<br />
// increase the diameter of our circle<br />
}<br />
public boolean isComposite() {<br />
return false;<br />
}<br />
</code><br />
Next up is another implementation of the component, but this time it will be a composite :<br />
<code><br />
public class Rectangle Component {<br />
private List children = new ArrayList();</code><code>public void draw() {<br />
foreach(component comp : children) {<br />
// actual implementation of our draw<br />
}</code><code>}<br />
public void growSize(int size) {<br />
foreach(component comp : children) {<br />
// increase the diameter of our circle<br />
}<br />
}</code><code>public List getChildren() {<br />
return children;<br />
}</code><code>public void addChild(Component child) {<br />
this.children.add(child);<br />
}</code><code>public void removeChild(Component child) {<br />
this.children.remove(child);<br />
}</code><code>public boolean isComposite() {<br />
return true;<br />
}<br />
}</code><br />
Now, as I mentioned at the beginning of this post, there are 2 implementations of this pattern. As you might already noticed, we use a method called isComposite() to determine if this object is a leaf or a composite, because at some point in our client classes we will probably have to know whether or not the object has children in order to access them directly. This is where our implementations of the composite pattern differ. This implementation uses the isComposite() to determine if it&#8217;s a composite and then preforms a cast in order to use the getChildren() removeChild() and addChild(). The other implementation has those methods in the interface, so you will be able to call them at any component ( leaf and composite ), the main advantage is that we don&#8217;t have to do the the check and the cast, but on the other hand, we have to implement the methods in our leafs as-well, which will be methods that just throw an exception.</p>
<p>More information on this pattern can be found at <a href="http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html?page=1" target="_blank">javaworld </a>or <a href="http://en.wikipedia.org/wiki/Composite_Pattern" target="_blank">wikipedia</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=13&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/14/using-the-composite-pattern/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/05/composite.jpg" medium="image">
			<media:title type="html">composite.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>The Strategy pattern explained</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/11/the-strategy-pattern-explained/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/11/the-strategy-pattern-explained/#comments</comments>
		<pubDate>Fri, 11 May 2007 09:09:49 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[gof]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[strategy]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/11/the-strategy-pattern-explained/</guid>
		<description><![CDATA[While looking into the code of our project I stumbled upon a part that I haven&#8217;t investigated before. The part is implemented with the strategy pattern, or so I was told because In fact the strategy pattern isn&#8217;t fully implemented. So I got curious about this pattern and found this nice definition by The gang of four :
Define a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=11&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>While looking into the code of our project I stumbled upon a part that I haven&#8217;t investigated before. The part is implemented with the strategy pattern, or so I was told because In fact the strategy pattern isn&#8217;t fully implemented. So I got curious about this pattern and found this nice definition by The gang of four :</p>
<blockquote><p>Define a family of algorithms, encapsulate each one, and make them interchangeable. [The] Strategy [pattern] lets the algorithm vary independently from clients that use it.</p></blockquote>
<p><span id="more-11"></span>In fact the strategy pattern can be used to avoid the use of big switch statements or if &#8211; elseif statements. What we do is, we create an interface and use this in our context class. This allows us to decouple the implementation and the usage for each other. The next step would be to create implementations of our strategies and and in order to use them we use a setter in the context class. Since explaining patterns is rather difficult without a UML scheme here it is :</p>
<blockquote><p><a href="http://thecorporatecode.files.wordpress.com/2007/05/strat.jpg" title="Strategy Pattern"><img border="0" align="middle" width="200" src="http://thecorporatecode.files.wordpress.com/2007/05/strat.jpg?w=200&#038;h=200" alt="Strategy Pattern" height="200" style="width:200px;height:200px;" /></a></p></blockquote>
<p>Sorry for the poor drawing but I had to make this in Visio which really sucks. As for the actual implementation I will show you a few code fragments to actually demonstrate the usage in Java.</p>
<p>We&#8217;ll start with the Context class. We should define a private member which is an implementation of the ICalcul interface.</p>
<p><code>public class ContextClass {<br />
 private ICalcul calcul = null;<br />
 private double result = 0.0;<br />
 .....<br />
 public void setCalcul(ICalcul calc) {<br />
  this.calcul = calc;<br />
 }<br />
public ICalCul getCalcul() {<br />
  return this.calcul;<br />
 }<br />
public void calculate() {<br />
  this.result = this.calcul.calculate();<br />
 }<br />
 ....<br />
}</code></p>
<p>As you can see in the above code fragment we use the interface in the ContextClass this allows us to decouple the actual implementation of the calculation from the ContextClass. This is very useful since now we can create any sort of calculation we want and decide at run-time which kind of calculation we want to use.  All we need to do now is create an implementation of our calculation.</p>
<p><code><br />
public class CalculA implements ICalcul {<br />
 public double calculate() {<br />
  return = 1.0/3.0;<br />
 }<br />
public void save() {<br />
  // do something here<br />
 }<br />
}</code><br />
There is our heavy calculation :) Now we can set the calculation we want in our application by doing the following<br />
<code><br />
public class Calculator {<br />
 .....<br />
 public static void main(String[] args) {<br />
  ....<br />
  ContextClass cc = new ContextClass();<br />
  ICalcul calc = new CalCulA();<br />
  cc.setCalcul(calc);<br />
  cc.calculate();<br />
  ....<br />
}<br />
}</code></p>
<p>If you want more information on this pattern I suggest you take a look on <a target="_blank" href="http://en.wikipedia.org/wiki/Strategy_pattern">wikipedia</a> or simply search for it with google.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=11&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/11/the-strategy-pattern-explained/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://thecorporatecode.files.wordpress.com/2007/05/strat.jpg" medium="image">
			<media:title type="html">Strategy Pattern</media:title>
		</media:content>
	</item>
		<item>
		<title>Caché, the next generation database ?</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/07/cache-the-next-generation-database/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/07/cache-the-next-generation-database/#comments</comments>
		<pubDate>Mon, 07 May 2007 13:25:16 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/07/cache-the-next-generation-database/</guid>
		<description><![CDATA[Found a nice presentation on Caché, an Object-oriented database. According to the presentation this database should boost your applications performance by 15% to 30%, which is a lot. And a reason for me not to thrust it, so I&#8217;ve download a copy of the framework, and a licence ( which appears to be free for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=10&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Found a nice presentation on Caché, an Object-oriented database. According to the presentation this database should boost your applications performance by 15% to 30%, which is a lot. And a reason for me not to thrust it, so I&#8217;ve download a copy of the framework, and a licence ( which appears to be free for personal use ) to test it tonight. After watching a few presentations about it, I think it&#8217;s a very nice framework, but I will try to post my personal opinion in a few days.</p>
<p>Watch the technology demo <a target="_blank" href="http://www.javalobby.org/eps/cache-jalapeno/?source=archives">here</a> and visit the homepage with this <a target="_blank" href="http://www.intersystems.com/cache/">link</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=10&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/07/cache-the-next-generation-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>
	</item>
		<item>
		<title>When IT hits the ghetto</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/03/when-it-hits-the-ghetto/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/03/when-it-hits-the-ghetto/#comments</comments>
		<pubDate>Thu, 03 May 2007 18:54:00 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/03/when-it-hits-the-ghetto/</guid>
		<description><![CDATA[Received a link from a colleague today, Its a fragment from a French tv show called striptease.  I guess the movie will explain the rest.
Enjoy !


       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=9&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Received a link from a colleague today, Its a fragment from a French tv show called striptease.  I guess the movie will explain the rest.</p>
<p>Enjoy !</p>
<p><span id="more-9"></span></p>
<p><span style="text-align:center; display: block;"><a href="http://thecorporatecode.wordpress.com/2007/05/03/when-it-hits-the-ghetto/"><img src="http://img.youtube.com/vi/OkqauMrSnWg/2.jpg" alt="" /></a></span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=9&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/03/when-it-hits-the-ghetto/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/OkqauMrSnWg/2.jpg" medium="image" />
	</item>
		<item>
		<title>And the winner is….</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/03/and-the-winner-is/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/03/and-the-winner-is/#comments</comments>
		<pubDate>Thu, 03 May 2007 17:48:57 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/03/and-the-winner-is/</guid>
		<description><![CDATA[Today, I received a mail from one of our team members in which he decided that we would have a competition. The winner will get a prize although we haven&#8217;t decided on what it should be. The competition is rather easy,  the one who wrote the worst piece of code in the application gets [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=8&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today, I received a mail from one of our team members in which he decided that we would have a competition. The winner will get a prize although we haven&#8217;t decided on what it should be. The competition is rather easy,  the one who wrote the worst piece of code in the application gets the prize. Since not everybody thought this competition was a good idea, it think we should change it a little bit, the one who finds the worst code and corrects it, gets the prize. This way, we avoid criticism and the point and laugh situations and create a fun learning experience, although the possibility to have a competition like this proves that a lot of the code is in poor shape.</p>
<p>As you might have noticed from my previous posts, I&#8217;ve been put in charge of refactoring pieces of the application to &#8220;clean up&#8221; the code. Although I find it really interesting to do, it&#8217;s also a time consuming task which is hard to justify, because if the job was well done from the beginning, it wouldn&#8217;t have been necessary.</p>
<p>On the other hand, nothing is perfect, and I guess that a project of this magnitude is hard to maintain, especially if only two people are in charge of keeping an eye on all the code. So in a way it might be justifiable to have some code in a lesser shape :)  And if everything would be perfectly written then we wouldn&#8217;t have a fun competition like this :)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=8&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/03/and-the-winner-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>
	</item>
		<item>
		<title>Refactoring a database layer</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/02/refactoring-a-database-layer/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/02/refactoring-a-database-layer/#comments</comments>
		<pubDate>Wed, 02 May 2007 12:43:24 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/02/refactoring-a-database-layer/</guid>
		<description><![CDATA[Last week I refactored the database layer of our application. Since the layer was pretty poorly implemented, I did a complete rework, meaning that a lot of classes had to be rewritten and put in new packages. Now the cool thing about all this is that with the new implementation it will be possible to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=6&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Last week I refactored the database layer of our application. Since the layer was pretty poorly implemented, I did a complete rework, meaning that a lot of classes had to be rewritten and put in new packages. Now the cool thing about all this is that with the new implementation it will be possible to hotplug another db layer into the application without changing any of the code inside the application. I&#8217;ve used a Factory class wich in fact is a singleton class, this allowed me to instantiate an actual Factory of choice, right now the application has only one implementation of the db layer, but we could create a completly different one ( read as : get rid of the crappy toplink and use hibernate instead :) ) . Below is the the getInstance() method wich does the magic for us :</p>
<p><code><br />
public static IPersistanceFactory getInstance() {<br />
if (instance == null) {<br />
logger.debug("Creating new IPersistanceFactory implementation : "<br />
+ implementation);<br />
Class clazz;<br />
try {<br />
clazz = Class.forName(implementation);<br />
instance = (IPersistanceFactory) clazz.newInstance();<br />
} catch (ClassNotFoundException e) {<br />
logger.error("Class not found : " + implementation, e);<br />
} catch (InstantiationException e) {<br />
logger.error("Can not instantiate class : " + implementation,e);<br />
} catch (IllegalAccessException e) {<br />
logger.error("Illegal access for class : " + implementation, e);<br />
}<br />
}<br />
logger.debug("Instance created !");<br />
return instance;<br />
}</code></p>
<p>The string with the implementation could possibly be in an application.properties file or something like that, this could allow us to externally decide wich db implementation we should use.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=6&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/02/refactoring-a-database-layer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>
	</item>
		<item>
		<title>Exception handling And Jsf, A nightmare !!</title>
		<link>http://thecorporatecode.wordpress.com/2007/05/01/exception-handling-is-an-option-well-take-the-risk/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/05/01/exception-handling-is-an-option-well-take-the-risk/#comments</comments>
		<pubDate>Tue, 01 May 2007 20:22:50 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/01/exception-handling-is-an-option-well-take-the-risk/</guid>
		<description><![CDATA[Since the application is rather huge, and exception handling isn&#8217;t something that has been taken into account when writing the drafts for JSF, it took me some time to find a decent way to implement exception handling. I came up with two possible solutions, but after further testing it turned out that only one of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=7&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Since the application is rather huge, and exception handling isn&#8217;t something that has been taken into account when writing the drafts for JSF, it took me some time to find a decent way to implement exception handling. I came up with two possible solutions, but after further testing it turned out that only one of them actually worked. Sadly it was the one that I felt, was the worst scenario.</p>
<p>First I tried to delegate the Faces servlet and tried to catch any exceptions there. that would have been a nice solution, since all exception handling would have been centralized and I wouldn&#8217;t have to have to much boiler plate code inside my application. But, as it turned out, this solution didn&#8217;t work :( After carefully testing the mock-up I had to come to the conclusion that delegating a Faces servlet is not a good way to go, certainly not a good way if your using<a target="_blank" href="http://www.icefaces.org"> icefaces</a>.</p>
<p>The second solution was rather nasty but, i went on with it anyway since I couldn&#8217;t find any better solution after searching the net. I let every exception get back to the event methods and catch it there. Once I had the exception there, I was able to pass it to an exception handler class, which would take care of the logging and displaying a nice pop up with some info for the user.</p>
<p>If you ever think of building a corporate application using JSF, don&#8217;t ! :) In my opinion it lacks some basic functionality and basically it isn&#8217;t ready for usage in real world applications yet. If you really want JSF then don&#8217;t use it as a stand-alone framework, I think it would be better to use it in combination with Spring or Struts.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=7&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/05/01/exception-handling-is-an-option-well-take-the-risk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>
	</item>
		<item>
		<title>My first post</title>
		<link>http://thecorporatecode.wordpress.com/2007/04/01/my-first-post/</link>
		<comments>http://thecorporatecode.wordpress.com/2007/04/01/my-first-post/#comments</comments>
		<pubDate>Sun, 01 Apr 2007 12:05:50 +0000</pubDate>
		<dc:creator>Tilleuil Doménique</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://thecorporatecode.wordpress.com/2007/05/02/my-first-post/</guid>
		<description><![CDATA[Hi,
Started a blog again, I hope that this time I will be able to keep posting on it, because I have a tendancy to forget to actually post something on it :) Anyway, I hope I will be able to keep my readers ( that is you ! ) informed and to keep them entertained [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=3&subd=thecorporatecode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hi,</p>
<p>Started a blog again, I hope that this time I will be able to keep posting on it, because I have a tendancy to forget to actually post something on it :) Anyway, I hope I will be able to keep my readers ( that is you ! ) informed and to keep them entertained with my random rantings about work.</p>
<p>Stay tuned, maybe someday there well be something usefull on this page :)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecorporatecode.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecorporatecode.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecorporatecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecorporatecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecorporatecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecorporatecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecorporatecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecorporatecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecorporatecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecorporatecode.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecorporatecode.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecorporatecode.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecorporatecode.wordpress.com&blog=1051427&post=3&subd=thecorporatecode&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thecorporatecode.wordpress.com/2007/04/01/my-first-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cf3bd32a9355d50458b3c998edd9309a?s=96&amp;d=identicon" medium="image">
			<media:title type="html">Ti_Uhl</media:title>
		</media:content>
	</item>
	</channel>
</rss>
