<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bijohnso</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bijohnso"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Bijohnso"/>
	<updated>2026-06-07T22:23:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69618</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69618"/>
		<updated>2012-11-16T21:28:48Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways. One of the better resources for any project is someone that has used the pattern before and blogs are a great place to start. One blog in particular gives a great explanation of the Decorator pattern being used in the Coffee example &amp;lt;ref name=&amp;quot;8lines&amp;quot;&amp;gt; http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html - 2006&amp;lt;/ref&amp;gt;. This is one of the sources that explicitly mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book, so it may be easy to use these resources in parallel.&lt;br /&gt;
&lt;br /&gt;
Another useful resource for implementing the Decorator pattern in Ruby written by another developer is on the site Programming = Fun &amp;lt;ref name=&amp;quot;decorators&amp;quot;&amp;gt; http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html -2011 &amp;lt;/ref&amp;gt;. One advantage this source has over the previous is that it is more up to date so it is less likely that there will be conflicting information with current knowledge and technology. This site uses the same coffee example but does not mention using the book so this may threaten how valid their interpretation is. Although they are both also about the same length in terms of words and code snippets, it seems that this one is more detailed in explaining what they did and why as they present the relevant code snippets. A disadvantage to using either of these resources is that if you are looking for variety or different ways of implementing the pattern they do not offer this information.&lt;br /&gt;
&lt;br /&gt;
If you are not sure how you want to use the Decorator but you believe you may want to use it, then the explanations given on Thoughtbot might be useful &amp;lt;ref name=&amp;quot;alternatives&amp;quot;&amp;gt; http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in - 2011 &amp;lt;/ref&amp;gt;. This source also uses the Coffee example, however looks at various ways of implementing the coffee example using the Decorator pattern. This source may be the most useful for examples because of the fact that it includes the example from the &amp;quot;Head First Design Patterns&amp;quot; book but also includes other alternatives that most other sites do not consider or explain. This source also has the advantage that is uses a good mix of textual explanations and code snippets to get the concepts across. A disadvantage is that if you are wanting more in depth explanations on the alternative methods they describe it may be difficult to find other sources that use similar examples but also explain them in more detail.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Ruby resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html  Decorators]&lt;br /&gt;
*[http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in  Alternatives]&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html Confessions of Ruby Programmer]&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Summary: Typical Wiki page&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory - Decorator Design Pattern]&lt;br /&gt;
**Summary: Quick reference of UML and participants&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern]&lt;br /&gt;
**Summary: Ice Cream example in Java&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Summary: Textbook chapter&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html confessions of a ruby programmer]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html Decorators in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in Evaluating alternative Decorator implementations in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Summary: Window example with Java snippets, checklist and rules of thumb&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Fwww.agiledeveloper.com%2Farticles%2FDecoratorByExample.pdf Decorator Pattern by Example]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ Design Pattern Series]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Summary: Code intensive GUI example in Java&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69617</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69617"/>
		<updated>2012-11-16T21:28:13Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways. One of the better resources for any project is someone that has used the pattern before and blogs are a great place to start. One blog in particular gives a great explanation of the Decorator pattern being used in the Coffee example &amp;lt;ref name=&amp;quot;8lines&amp;quot;&amp;gt; http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html - 2006&amp;lt;/ref&amp;gt;. This is one of the sources that explicitly mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book, so it may be easy to use these resources in parallel.&lt;br /&gt;
&lt;br /&gt;
Another useful resource for implementing the Decorator pattern in Ruby written by another developer is on the site Programming = Fun &amp;lt;ref name=&amp;quot;decorators&amp;quot;&amp;gt; http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html -2011 &amp;lt;/ref&amp;gt;. One advantage this source has over the previous is that it is more up to date so it is less likely that there will be conflicting information with current knowledge and technology. This site uses the same coffee example but does not mention using the book so this may threaten how valid their interpretation is. Although they are both also about the same length in terms of words and code snippets, it seems that this one is more detailed in explaining what they did and why as they present the relevant code snippets. A disadvantage to using either of these resources is that if you are looking for variety or different ways of implementing the pattern they do not offer this information.&lt;br /&gt;
&lt;br /&gt;
If you are not sure how you want to use the Decorator but you believe you may want to use it, then the explanations given on Thoughtbot might be useful &amp;lt;ref name=&amp;quot;alternatives&amp;quot;&amp;gt; http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in - 2011 &amp;lt;/ref&amp;gt;. This source also uses the Coffee example, however looks at various ways of implementing the coffee example using the Decorator pattern. This source may be the most useful for examples because of the fact that it includes the example from the &amp;quot;Head First Design Patterns&amp;quot; book but also includes other alternatives that most other sites do not consider or explain. This source also has the advantage that is uses a good mix of textual explanations and code snippets to get the concepts across. A disadvantage is that if you are wanting more in depth explanations on the alternative methods they describe it may be difficult to find other sources that use similar examples but also explain them in more detail.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Ruby resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html  Decorators]&lt;br /&gt;
*[http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in  Alternatives]&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html 8 Lines]&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Summary: Typical Wiki page&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory - Decorator Design Pattern]&lt;br /&gt;
**Summary: Quick reference of UML and participants&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern]&lt;br /&gt;
**Summary: Ice Cream example in Java&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Summary: Textbook chapter&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html confessions of a ruby programmer]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html Decorators in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in Evaluating alternative Decorator implementations in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Summary: Window example with Java snippets, checklist and rules of thumb&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Fwww.agiledeveloper.com%2Farticles%2FDecoratorByExample.pdf Decorator Pattern by Example]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ Design Pattern Series]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Summary: Code intensive GUI example in Java&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69616</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69616"/>
		<updated>2012-11-16T21:25:39Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways. One of the better resources for any project is someone that has used the pattern before and blogs are a great place to start. One blog in particular gives a great explanation of the Decorator pattern being used in the Coffee example &amp;lt;ref name=&amp;quot;8lines&amp;quot;&amp;gt; http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html - 2006&amp;lt;/ref&amp;gt;. This is one of the sources that explicitly mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book, so it may be easy to use these resources in parallel.&lt;br /&gt;
&lt;br /&gt;
Another useful resource for implementing the Decorator pattern in Ruby written by another developer is on the site Programming = Fun &amp;lt;ref name=&amp;quot;decorators&amp;quot;&amp;gt; http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html -2011 &amp;lt;/ref&amp;gt;. One advantage this source has over the previous is that it is more up to date so it is less likely that there will be conflicting information with current knowledge and technology. This site uses the same coffee example but does not mention using the book so this may threaten how valid their interpretation is. Although they are both also about the same length in terms of words and code snippets, it seems that this one is more detailed in explaining what they did and why as they present the relevant code snippets. A disadvantage to using either of these resources is that if you are looking for variety or different ways of implementing the pattern they do not offer this information.&lt;br /&gt;
&lt;br /&gt;
If you are not sure how you want to use the Decorator but you believe you may want to use it, then the explanations given on Thoughtbot might be useful &amp;lt;ref name=&amp;quot;alternatives&amp;quot;&amp;gt; http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in - 2011 &amp;lt;/ref&amp;gt;. This source also uses the Coffee example, however looks at various ways of implementing the coffee example using the Decorator pattern. This source may be the most useful for examples because of the fact that it includes the example from the &amp;quot;Head First Design Patterns&amp;quot; book but also includes other alternatives that most other sites do not consider or explain. This source also has the advantage that is uses a good mix of textual explanations and code snippets to get the concepts across. A disadvantage is that if you are wanting more in depth explanations on the alternative methods they describe it may be difficult to find other sources that use similar examples but also explain them in more detail.&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Summary: Typical Wiki page&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory - Decorator Design Pattern]&lt;br /&gt;
**Summary: Quick reference of UML and participants&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern]&lt;br /&gt;
**Summary: Ice Cream example in Java&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Summary: Textbook chapter&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html confessions of a ruby programmer]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html Decorators in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in Evaluating alternative Decorator implementations in Ruby]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Summary: Window example with Java snippets, checklist and rules of thumb&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Fwww.agiledeveloper.com%2Farticles%2FDecoratorByExample.pdf Decorator Pattern by Example]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ Design Pattern Series]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Summary: Code intensive GUI example in Java&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69613</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69613"/>
		<updated>2012-11-16T21:22:36Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways. One of the better resources for any project is someone that has used the pattern before and blogs are a great place to start. One blog in particular gives a great explanation of the Decorator pattern being used in the Coffee example &amp;lt;ref name=&amp;quot;8lines&amp;quot;&amp;gt; http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html - 2006&amp;lt;/ref&amp;gt;. This is one of the sources that explicitly mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book, so it may be easy to use these resources in parallel.&lt;br /&gt;
&lt;br /&gt;
Another useful resource for implementing the Decorator pattern in Ruby written by another developer is on the site Programming = Fun &amp;lt;ref name=&amp;quot;decorators&amp;quot;&amp;gt; http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html -2011 &amp;lt;/ref&amp;gt;. One advantage this source has over the previous is that it is more up to date so it is less likely that there will be conflicting information with current knowledge and technology. This site uses the same coffee example but does not mention using the book so this may threaten how valid their interpretation is. Although they are both also about the same length, it seems that this one is more detailed in explaining what they did and why as they present the relevant code snippets. &lt;br /&gt;
&lt;br /&gt;
If you are not sure how you want to use the Decorator but you believe you may want to use it, then the explanations given on Thoughtbot might be useful &amp;lt;ref name=&amp;quot;alternatives&amp;quot;&amp;gt; http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in - 2011 &amp;lt;/ref&amp;gt;. This source also uses the Coffee example, however looks at various ways of implementing the coffee example using the Decorator pattern. This source may be the most useful for examples because of the fact that it includes the example from the &amp;quot;Head First Design Patterns&amp;quot; book but also includes other alternatives that most other sites do not consider or explain. This source also has the advantage that is uses a good mix of textual explanations and code snippets to get the concepts across. A disadvantage is that if you are wanting more in depth explanations on the alternative methods they describe it may be difficult to find other sources that use similar examples but also explain them in more detail.&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Summary: Typical Wiki page&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory - Decorator Design Pattern]&lt;br /&gt;
**Summary: Quick reference of UML and participants&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern]&lt;br /&gt;
**Summary: Ice Cream example in Java&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Summary: Textbook chapter&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html confessions of a ruby programmer]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Summary: Window example with Java snippets, checklist and rules of thumb&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Fwww.agiledeveloper.com%2Farticles%2FDecoratorByExample.pdf Decorator Pattern by Example]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ Design Pattern Series]&lt;br /&gt;
**Summary: &lt;br /&gt;
**Pro: &lt;br /&gt;
**Con: &lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Summary: Code intensive GUI example in Java&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69609</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69609"/>
		<updated>2012-11-16T21:12:53Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways. One of the better resources for any project is someone that has used the pattern before and blogs are a great place to start. One blog in particular gives a great explanation of the Decorator pattern being used in the Coffee example &amp;lt;ref name=&amp;quot;8lines&amp;quot;&amp;gt; http://lukeredpath.co.uk/blog/decorator-pattern-with-ruby-in-8-lines.html - 2006&amp;lt;/ref&amp;gt;. This is one of the sources that explicitly mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book, so it may be easy to use these resources in parallel.&lt;br /&gt;
&lt;br /&gt;
Another useful&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69608</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69608"/>
		<updated>2012-11-16T21:08:47Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways.&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69607</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69607"/>
		<updated>2012-11-16T21:08:12Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
Understanding the general concepts behind using the Decorator pattern would be the first step for any language implementation. The next step is usually finding examples that show how the pattern can be used, possibly by language. Here we will look at sources that give useful examples for understanding how to implement the Decorator pattern in Ruby. It is also worth noting that all references cited in this wiki are useful for understanding the pattern in general, despite the language that may be used in the examples.&lt;br /&gt;
&lt;br /&gt;
The most popular example used to explain the Decorator pattern in Ruby is an example involving a Coffee class, of which there are various subclasses of coffee that can have various additional ingredients (milk, sugar, etc.). For many of the sites, they mentioned using the &amp;quot;Head First Design Patterns&amp;quot; book as a source, so of course we recommend the same &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;. The biggest disadvantage to using this resource is that it is a part of a textbook so is rather lengthy. There are a variety of sites devoted to explaining this pattern (most of which use the Coffee example) but a few stood out as especially useful in various ways.&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
**Pro: The UML diagram is nice and the code is quite complete. The concrete example is applicable to the real world.&lt;br /&gt;
**Con: The page does not provide too much explanation, mainly just a code sample.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69604</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69604"/>
		<updated>2012-11-16T21:01:13Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Java &amp;amp; C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Overview of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For a general overview and UML diagrams of the Decorator design pattern, we recommend:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt;; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.&lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot;&amp;lt;ref name=&amp;quot;head_first&amp;quot;/&amp;gt; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers&amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012?&amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the &amp;quot;Decorator Pattern by Example&amp;quot; page may be more helpful &amp;lt;ref name=&amp;quot;dpexample&amp;quot;&amp;gt; http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt;http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt;http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?&amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
For Java and C# resources, we recommend:&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]&lt;br /&gt;
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]&lt;br /&gt;
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69600</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69600"/>
		<updated>2012-11-16T20:53:25Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Java &amp;amp; C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Description of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
The resources we recommend for this section are:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;; in this book an in-depth explanation of the Decorator Pattern can be found &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004&amp;lt;/ref&amp;gt;. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.  &lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional  developers &amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012? &amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example).&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt; http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com &amp;lt;ref name=&amp;quot;gui&amp;quot;&amp;gt; http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ? &amp;lt;/ref&amp;gt;. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69599</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69599"/>
		<updated>2012-11-16T20:47:39Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Java &amp;amp; C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Description of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
The resources we recommend for this section are:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;; in this book an in-depth explanation of the Decorator Pattern can be found &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004&amp;lt;/ref&amp;gt;. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.  &lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional  developers &amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012? &amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example).&lt;br /&gt;
&lt;br /&gt;
Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics &amp;lt;ref name=&amp;quot;soccer&amp;quot;&amp;gt; http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 &amp;lt;/ref&amp;gt;. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own &amp;quot;problem&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69598</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69598"/>
		<updated>2012-11-16T20:37:32Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Java &amp;amp; C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Description of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern - 2012&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx - 2001 - 2012&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and discusses use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/ - 2011&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Understand the UML diagram for the Decorator pattern can help you understand the purpose of the Decorator pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.&lt;br /&gt;
&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004 - 2008&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
The resources we recommend for this section are:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia]&lt;br /&gt;
*[http://www.dofactory.com/Patterns/PatternDecorator.aspx dofactory]&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers]&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;; in this book an in-depth explanation of the Decorator Pattern can be found &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004&amp;lt;/ref&amp;gt;. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.  &lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional  developers &amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012? &amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example).&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
*[http://sourcemaking.com/design_patterns/decorator SourceMaking - Decorator Design Pattern]&lt;br /&gt;
**Pro: This page presents an interesting concrete example with UML diagrams and code snippets. At the end, it covers a checklist for using the Decorator pattern as well as some rules of thumb.&lt;br /&gt;
**Con: The code provided in this resource are just snippets, not a full example.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69591</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w59 bc</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w59_bc&amp;diff=69591"/>
		<updated>2012-11-16T20:11:11Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Java &amp;amp; C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Decorator Directory=&lt;br /&gt;
&lt;br /&gt;
==General Resources==&lt;br /&gt;
===Description of the Pattern===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Decorator_pattern&amp;lt;/ref&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;&amp;gt;http://www.dofactory.com/Patterns/PatternDecorator.aspx&amp;lt;/ref&amp;gt; provide solid explanations of the Decorator Pattern. dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; is much more concise than Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt;, on the other hand, is much more verbose, but goes into the motivation for the pattern and talks use of the patterns in several languages at a high level.&lt;br /&gt;
&lt;br /&gt;
If you understand Java (or a Java like language), javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;&amp;gt;http://javapapers.com/design-patterns/decorator-pattern/&amp;lt;/ref&amp;gt; is a good page that gives a basic overview of the pattern through the presentation of a concrete example. There are other Java resources and resources for other languages that are similar below.&lt;br /&gt;
&lt;br /&gt;
===UML===&lt;br /&gt;
Wikipedia&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;/&amp;gt; and dofactory&amp;lt;ref name=&amp;quot;dofactory&amp;quot;/&amp;gt; both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers&amp;lt;ref name=&amp;quot;javapapers&amp;quot;/&amp;gt; provides an Ice Cream example and Head First Design Patterns&amp;lt;ref name=&amp;quot;head_first&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf&amp;lt;/ref&amp;gt; provides a couple as well, but it is a very long read. Many of the language specific resources listed later in this article also provide UML diagrams for their concrete examples/implementations.&lt;br /&gt;
&lt;br /&gt;
==Ruby==&lt;br /&gt;
&lt;br /&gt;
==Java &amp;amp; C#==&lt;br /&gt;
&lt;br /&gt;
There are a variety of resources available for learning how to use the Decorator pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book &amp;quot;Head First Design Patterns&amp;quot;; in this book an in-depth explanation of the Decorator Pattern can be found &amp;lt;ref name=&amp;quot;headfirst&amp;quot;&amp;gt;https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004&amp;lt;/ref&amp;gt;. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to &amp;quot;decorate&amp;quot; your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.  &lt;br /&gt;
&lt;br /&gt;
If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the &amp;quot;Head First Design Patterns&amp;quot; book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional  developers &amp;lt;ref name=&amp;quot;sourcemaking&amp;quot;&amp;gt; http://sourcemaking.com/design_patterns/decorator - 2012? &amp;lt;/ref&amp;gt;. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern.&lt;br /&gt;
&lt;br /&gt;
==Directory==&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Decorator_pattern Wikipedia - Decorator Pattern]&lt;br /&gt;
**Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.&lt;br /&gt;
**Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).&lt;br /&gt;
*[http://www.google.com/url?q=http%3A%2F%2Fwww.dofactory.com%2FPatterns%2FPatternDecorator.aspx&amp;amp;sa=D&amp;amp;sntz=1&amp;amp;usg=AFQjCNGFh9wp9H2FSxI5drUZfg4YE-Au3g dofactory - Decorator Design Pattern]&lt;br /&gt;
**Pro: Provides a quick definition, list of participants and abstract UML diagram.&lt;br /&gt;
**Con: Not much of an explanation - just good for referencing.&lt;br /&gt;
*[http://javapapers.com/design-patterns/decorator-pattern/ javapapers - Decorator Design Pattern (Java)]&lt;br /&gt;
**Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.&lt;br /&gt;
**Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.&lt;br /&gt;
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]&lt;br /&gt;
**Pro: Is a excerpt from a commercial textbook, so the source is extremely credible and provides an in depth explanation of the design pattern complete with UML and a concrete example.&lt;br /&gt;
**Con: The textbook does not appear too professional and provides a lot of background that isn't really necessary for understanding the pattern. This is very long read.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w10_pk&amp;diff=64272</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w10 pk</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w10_pk&amp;diff=64272"/>
		<updated>2012-09-14T03:12:41Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2012/ch1_1w25 previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming] is where the computer code interacts with other programs as data and performs many of these interactions at compile time rather than runtime.  This built-in interaction allows the programmers to take advantage of these capabilities and focus their time on the rest of their program logic instead of the details of some of the lower level coding.  In this article, we will take a closer look at one of the styles of metaprogramming referred to as language extensions for [http://en.wikipedia.org/wiki/Object-relational_mapping object-relational mapping] through examples and some comparisons of language extensions and tools.&lt;br /&gt;
&lt;br /&gt;
==Object-Relational Mapping==&lt;br /&gt;
Object-Relational Mapping (ORM) is a methodology for managing data between object oriented systems and relational databases.  The premise of the concept is to provide a universal method to access data in a database.  This is beneficial for all programming languages that can use objects to store and retrieve data from the database.  There are many languages that are using ORM as a technique to manage database data.  In the rest of the article, we will discuss ORM and some of the languages in use today.&lt;br /&gt;
&lt;br /&gt;
==Language Extensions==&lt;br /&gt;
Language extensions for ORM have often been traditionally classified as design patterns or software tools used to perform basic [http://en.wikipedia.org/wiki/Create,_read,_update_and_delete create, read, update and delete (C.R.U.D.)] operations on relational databases, that is, until recent new approaches such as [http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord] have grown in popularity.  ActiveRecord is not just a design pattern it is an increase of function to the active record pattern approach by adding [http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29 inheritance] and [http://en.wikipedia.org/wiki/Association_%28object-oriented_programming%29 associations].  Examining ActiveRecord and other language extensions will allow for comparisons of the ease of programming using these language extensions verses the conventional database oriented systems approach.&lt;br /&gt;
&lt;br /&gt;
==Ruby and ActiveRecord==&lt;br /&gt;
All too often programmers are faced with the challenge of persisting objects from their program into a datastore.  Custom code is created for this purpose that can be complex or difficult for others to understand as well as not seem natural.  Applications that are designed to persist data have the need to know how the objects correspond to the information stored in these database tables.  [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails], first released in 2005, is able to provide a uniform method to help resolve these complicated issues without sacrificing function or knowledge of these objects by using ActiveRecord (AR).  AR is a persistence engine that comes as part of Ruby on Rails.  &amp;quot;''It creates a 'persistable' domain model from business objects and database tables, where logic and data are presented as a unified package''&amp;quot; [http://en.wikipedia.org/wiki/ActiveRecord#Ruby 3].  AR is admired for its simplistic and elegant approach of removing these levels of complexity.  It allows for a 'pluggable' solution to many different popular databases available today to include: [http://en.wikipedia.org/wiki/MySQL MySQL], [http://en.wikipedia.org/wiki/SQLite SQLite], [http://en.wikipedia.org/wiki/Microsoft_SQL_Server SQL Server], [http://en.wikipedia.org/wiki/PostgreSQL PostgreSQL], and [http://en.wikipedia.org/wiki/Oracle_Database Oracle].  &lt;br /&gt;
&lt;br /&gt;
ActiveRecord uses a [http://en.wikipedia.org/wiki/Single_Table_Inheritance Single Table Inheritance] to allow for inheritance capabilities and provides a set of macros for association relationships between classes of objects, such as belongs_to, has_one, has_many, etc.  AR is not only a component of the [http://en.wikipedia.org/wiki/Model-view-controller Model view-controller (MVC)] for Ruby on Rails but it is also a standalone ORM package for Ruby itself.  Ruby, Ruby on Rails, and ActiveRecord continue to grow in popularity due to not only the curiosity of programmers but their ability to improve function and feature sets while maintaining the initial intent of the language, &amp;quot;''trying to make Ruby natural, not simple''&amp;quot; -- Yukihiro “matz” Matsumoto [http://www.ruby-lang.org/en/about/ 8].  Other languages have been able to learn from AR and have tried to add this capability for themselves.  Let’s take a closer look at some other implementations that attempts to duplicate AR’s elegance.&lt;br /&gt;
&lt;br /&gt;
==Other Examples of Language Extensions==&lt;br /&gt;
===ADO.NET Entity Framework===&lt;br /&gt;
[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework], Microsoft's ORM, part of [http://en.wikipedia.org/wiki/.NET_Framework .NET] 4.0 was first developed in 2008.  The Entity Framework tries to remove ORM mismatches that often plague conventional database oriented programs by using an Entity data model (EDM) and an Entity-Relationship data model to define the Relationships associated to each Entity.  The EDM consists of a schema and a mapping specification.  The schema defines the data types from the entities and the mapping provides the connections between the database scheme and the conceptual scheme. The Entity Framework has its own version of a query language called Entity SQL which continues to focus only on the conceptual entities and relationships as opposed to the actual database.  It works with many popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.&lt;br /&gt;
&lt;br /&gt;
===Django===&lt;br /&gt;
Python, presents an interesting case because it is an extremely similar language to Ruby in syntax and somewhat in philosophy. &lt;br /&gt;
[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django], is an ORM included in Django open source framework for Python.  It follows a MVC [http://en.wikipedia.org/wiki/Architectural_pattern_%28computer_science%29 architectural pattern] and was originally released in 2005 with the primary goal of making complex, database driven websites easier to create and maintain.  Instilled in its principles are emphasis on loose coupling, rapid development, [http://en.wikipedia.org/wiki/Don%27t_repeat_yourself don’t repeat yourself], and reusability (a.k.a. less code).  The basis of its design is to encapsulate objects just like the ActiveRecord design pattern in models so that all the information needed can be stored in the model and knowledge of the database is not exposed. Django can essentially be considered the equivalent to Rails for Ruby.&lt;br /&gt;
&lt;br /&gt;
===Enterprise Objects Framework===&lt;br /&gt;
Lastly we will introduce [http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework (EOF)], Mac OS X/Java, part of Apple [http://en.wikipedia.org/wiki/WebObjects WebObjects].  EOF is the oldest of the bunch, introduced in 1994 for a product call [http://en.wikipedia.org/wiki/NeXTSTEP NeXTSTEP].  It was indented to eliminate the interaction with the [http://en.wikipedia.org/wiki/Relational_database relational database] and the Java or Objective-C objects.  EOF was later integrated into WebObjects.  An EOFModel contains the mappings from the database to the classes, class attributes, and objects.  EOF also incorporates inheritance into its feature set to allow a more object oriented approach using Enterprise Objects to reflect the hierarchy.  EOF uses [http://en.wikipedia.org/wiki/Jdbc Java Database Connectivity (JDBC)] and [http://en.wikipedia.org/wiki/JNDI Java Naming and Directory Interface (JNDI)] to talk to databases that support that, such as Oracle, DB2, and MySQL.&lt;br /&gt;
===Java's Hibernate===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate] is Java’s ORM framework library that maps Java classes to database tables and provides data query and retrieval functionality via XML mappings done though Java Annotations configurations. In addition, it can generate SQL calls that lessen the need for developers to convert result sets into objects manually.&lt;br /&gt;
One of the first things that Hibernate uses for any interactions is a Session Factory class which is designed as a [http://en.wikipedia.org/wiki/Factory_method_pattern class factory] to return the current Hibernate session object and ensure that only one instance of the session be issued per thread. Without listing the actual code of the Session Factory the code basically allows for getting the session object, opening the session for use, and closing the session after use.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, Hibernate database table creation can only be done manually using separate tools or additional Java code. This is a prime example of the additional knowledge a developer must have to correctly create a hibernate project. A developer must know that each object type must have its own table and that the fields within the table must correspond to the types of the object’s member variables.&lt;br /&gt;
&lt;br /&gt;
Based on the tables created, classes must then be created with the member variables and setters/getters associated with the field types created in the database. For example, if the database table contains a field 'name' which is of type varchar and limited to 255 characters, the setter/getter must be of type String and the coder (if they wish) may limit the entry in the setter to 255 characters.&lt;br /&gt;
&lt;br /&gt;
The next step is to create a Hibernate configuration file which essentially defines the database connection including the url, username, database type, password, etc. After this, the developer must explicitly tell Hibernate the relationships between the member variables of the class and the fields of the database with either an xml file or using Java annotations inside of the class. This is yet another example of the extra effort that has to be taken by the developer, but which also gives the developer great power and flexibility to name the fields and member variables different things.&lt;br /&gt;
&lt;br /&gt;
===JazzRecord for JavaScript===&lt;br /&gt;
&lt;br /&gt;
JavaScript presents another good case study for the use of ORM and ActiveRecord in application development. For one, JavaScript, like Python and Ruby, is loosely typed which can make dealing with the strictness of database typing an interesting challenge for these languages. Secondly, JazzRecord was modeled specifically after ActiveRecord in Ruby but does have its own differences.&lt;br /&gt;
&lt;br /&gt;
==Programming using Language Extensions==&lt;br /&gt;
Several language extensions have been introduced in previous sections of the article.  &lt;br /&gt;
Let's take a closer look at a specific scenario and show how each of them would implement their respective table for multiple language packages. In some of the examples below you will see that many of the language extensions require external tools to generate the hooks in to the language.&lt;br /&gt;
&lt;br /&gt;
To illustrate the differences in implementation of ORM in different language packages, we will use the following example: &lt;br /&gt;
'''Products and Categories.''' &lt;br /&gt;
&lt;br /&gt;
A Category can have many Products but a Product can only have one Category. A sample query would be &lt;br /&gt;
&amp;lt;pre&amp;gt;SELECT product.productName &amp;amp; product.unitPrice FROM Products WHERE product.category.categoryName = “Beverages” &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ActiveRecord===&lt;br /&gt;
For ActiveRecord in Ruby on Rails, the syntax to create the table is contained within the Product class that inherits from the ActiveRecord class.  No external tools are required to generate the Ruby code, only the Ruby interpreter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :product do |p|&lt;br /&gt;
      p.string :name&lt;br /&gt;
      p.string :id&lt;br /&gt;
      p.string :category&lt;br /&gt;
      p.float :unitPrice&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :product&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now create a new Product in Ruby, update the attributes, and save the object.  The .save method will actually update the database table. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n = Product.new&lt;br /&gt;
n.id = &amp;quot;1&amp;quot;&lt;br /&gt;
n.name = &amp;quot;Coke&amp;quot;&lt;br /&gt;
n.category = &amp;quot;beverage&amp;quot;&lt;br /&gt;
n.unitPrice = 0.99&lt;br /&gt;
n.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ADO.NET Entity Framework===&lt;br /&gt;
&lt;br /&gt;
ADO.NET requires that you use the [http://msdn.microsoft.com/en-us/library/bb738483.aspx Entity Model Designer] which is part of [http://msdn.microsoft.com/en-us/vstudio/default.aspx Microsoft Visual Studio].  The Designer allows you to create your model which includes any entities and associations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Designer will ultimately generate an XML file that represents the Entity Data Model.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- A snippit from the xml file – shows the Product definion --&amp;gt;&lt;br /&gt;
&amp;lt;!-- There are not associations in out example --&amp;gt;&lt;br /&gt;
&amp;lt;EntityType Name = &amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Name&amp;quot; Type = &amp;quot;String&amp;quot; /&amp;gt; &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Category&amp;quot; Type = &amp;quot;String&amp;quot; /&amp;gt; &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Unit Price&amp;quot; Type = &amp;quot;Float&amp;quot; /&amp;gt;           &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;id&amp;quot; Type = &amp;quot;String&amp;quot; Nullable = &amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/EntityType&amp;gt;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In code for the Product object, the setter on the class would look something like this.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set&lt;br /&gt;
{&lt;br /&gt;
   this.CategoryReference.EntityKey = new EntityKey(&amp;quot;ProductEntities.Category&amp;quot;, &amp;quot;id&amp;quot;, &amp;quot;name&amp;quot;, &amp;quot;unitPrice&amp;quot;, &amp;quot;category&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Django===&lt;br /&gt;
&lt;br /&gt;
In Django, a model is defined to represent a product. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  from django.db import models&lt;br /&gt;
  class Product(models.Model):&lt;br /&gt;
    name= models.CharField(max_length=200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After creating a model for a product it will generate a corresponding table.&lt;br /&gt;
Note that &amp;quot;id&amp;quot; is included as part of the model, so this might cause some unexpected issues if you planned to use id differently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  BEGIN;&lt;br /&gt;
  CREATE TABLE myapp_product (&lt;br /&gt;
    &amp;quot;id&amp;quot; serial NOT NULL PRIMARY KEY,&lt;br /&gt;
          &amp;quot;name&amp;quot; varchar(200),&lt;br /&gt;
          &amp;quot;category&amp;quot; varchar(200),&lt;br /&gt;
          &amp;quot;unitPrice&amp;quot; decimal&lt;br /&gt;
  );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a new instance of a Product and save it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
p =  Product(name='Coke', category='beverage', unitPrice=0.99)&lt;br /&gt;
p.save()&lt;br /&gt;
p.id     # Returns the ID of your new object.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enterprise Objects Framework===&lt;br /&gt;
The biggest downside with EOF and WebObjects is that it is not free.  The Server and development environment is fairly expensive.  However, here is a quick look at how you would create an EOF model that represents the classes, attributes and the objects.&lt;br /&gt;
&lt;br /&gt;
To generate the Product definition developers must use the [http://www.mactech.com/articles/mactech/Vol.16/16.10/BuildanEOModel/index.html EOModeler UI].&lt;br /&gt;
&lt;br /&gt;
The code to create a new instance / database entry is fairly intuitive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   EOEditingContext ep =  new EOEditingContext();&lt;br /&gt;
&lt;br /&gt;
   Product p =  new Product();&lt;br /&gt;
   p.id = &amp;quot;1&amp;quot;;&lt;br /&gt;
   p.name = &amp;quot;Coke&amp;quot;;&lt;br /&gt;
   p.category = &amp;quot;beverage&amp;quot;;&lt;br /&gt;
   p.unitPrice = 0.99;&lt;br /&gt;
 &lt;br /&gt;
   ep.add(p);&lt;br /&gt;
   ep.saveChanges();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java Hibernate===&lt;br /&gt;
There is no question that the set up effort involved in getting a Hibernate project going is substantially more than in ActiveRecord for Rails. The actual code to create and manipulate the objects is approximately the same between the two languages. This is clearly a case where more power is given to the developer but it is not without cost, which in this case is a fairly complex and involved list of set up steps.&lt;br /&gt;
&lt;br /&gt;
Below is an example set up for a Hibernate transaction&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product p = new Product();&lt;br /&gt;
p.name(&amp;quot;Coke&amp;quot;);&lt;br /&gt;
p.category(&amp;quot;Beverage&amp;quot;);&lt;br /&gt;
p.unitPrice(0.99)&lt;br /&gt;
&lt;br /&gt;
Transaction tx = null;&lt;br /&gt;
Session s1 = SessionFactory.getInstance().getCurrentSession();&lt;br /&gt;
try &lt;br /&gt;
{&lt;br /&gt;
   tx = session.beginTransaction();&lt;br /&gt;
   s1.save(p);&lt;br /&gt;
   tx.commit();&lt;br /&gt;
}&lt;br /&gt;
catch(RuntimeException e) &lt;br /&gt;
{&lt;br /&gt;
   tx.rollback();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===JStORM for Javascript===&lt;br /&gt;
Example adapted from [http://ajaxian.com/archives/jstorm-a-new-javascript-object-relational-mapper Ajaxian]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
JStORM is very similar to Rails in which we define a Model that will hold our Products&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var Product = new JStORM.Model({&lt;br /&gt;
  name:&amp;quot;Product&amp;quot;, // the first argument is the table name to use in the db.&lt;br /&gt;
  fields: { // the second argument is an object that defines the table columns&lt;br /&gt;
// the keys are the column names and the values are the column types (limited to Integer,Float,TimeStamp and String)&lt;br /&gt;
// The additional sql properties can be defined: notNull, defaultValue, maxLength, unique&lt;br /&gt;
     productName:new JStORM.Field({type:&amp;quot;String&amp;quot;,maxLength:25}),&lt;br /&gt;
     category:new JStORM.Field({type:&amp;quot;String&amp;quot;, maxLength:25}),&lt;br /&gt;
     unitPrice:new JStORM.Field({type:&amp;quot;Float&amp;quot;}),&lt;br /&gt;
  },&lt;br /&gt;
  connection:&amp;quot;default&amp;quot;&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basic SQL operations are one line code statements&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product.createTable(); // creates the table&lt;br /&gt;
Product.insert([&amp;quot;Coke&amp;quot;,&amp;quot;beverages&amp;quot;]); // insert Coke beverage into Product table&lt;br /&gt;
Product.insert([&amp;quot;PBR&amp;quot;,&amp;quot;beverages&amp;quot;]); // insert PBR&lt;br /&gt;
Product.select(&amp;quot;category = 'beverages'&amp;quot;) // selects products of category beverages&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Jazz Record for Javascript===&lt;br /&gt;
Declaring a model in JazzRecord is very similar to ActiveRecord in structure, where the types of each of the fields must be explicitly identified so that the correct table can be created.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var Products = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;products&amp;quot;,&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;Coke&amp;quot;,&lt;br /&gt;
    category: &amp;quot;beverage&amp;quot;,&lt;br /&gt;
    unitPrice: 0.99&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Like ActiveRecord, retrieving objects from the database is effortless and very transparent. Here is an example of querying a few objects and then using those objects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var product1 = Products.findBy(&amp;quot;name&amp;quot;, &amp;quot;Coke&amp;quot;);&lt;br /&gt;
var product2 = Products.findBy(&amp;quot;category&amp;quot;, &amp;quot;beverage&amp;quot;);&lt;br /&gt;
var sameProduct = (product.name == product2.name);&lt;br /&gt;
product2.name = &amp;quot;NewProduct&amp;quot;;&lt;br /&gt;
product2.save();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The JazzRecord team even decided to follow ActiveRecord in including the ability to identify associations between the different models. The following is an example of how to define associations between two models:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//new version of JazzLegend model&lt;br /&gt;
Category = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;categories&amp;quot;,&lt;br /&gt;
  foreignKey: &amp;quot;product_id&amp;quot;,&lt;br /&gt;
  hasMany: {products: &amp;quot;products&amp;quot;},&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;beverage&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
//associated model&lt;br /&gt;
Product = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;products&amp;quot;,&lt;br /&gt;
  belongsTo: {category: &amp;quot;categories&amp;quot;},&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;text&amp;quot;,&lt;br /&gt;
    unitPrice: 0.99,&lt;br /&gt;
    category_id: &amp;quot;1&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ODB for C++===&lt;br /&gt;
Example adapted from [http://www.codesynthesis.com/products/odb/ Code Synthesis]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #pragma db object&lt;br /&gt;
  class product&lt;br /&gt;
  {&lt;br /&gt;
    ...&lt;br /&gt;
  private:&lt;br /&gt;
    product ();&lt;br /&gt;
&lt;br /&gt;
    #pragma db id auto&lt;br /&gt;
    unsigned long id_;&lt;br /&gt;
&lt;br /&gt;
    string productName_;&lt;br /&gt;
    string category_;&lt;br /&gt;
    float unitPrice_;&lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Given the above declarations, we can perform various database operations with objects of the product class:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 product coke (&amp;quot;Coca-Cola&amp;quot;, “beverages”, 0.99);&lt;br /&gt;
 product pbr (&amp;quot;Pabst Blue Ribbon&amp;quot;, “beverages”, 1.99);&lt;br /&gt;
 odb::transaction t (db.begin ());&lt;br /&gt;
db.persist (coke);&lt;br /&gt;
db.persist (pbr);&lt;br /&gt;
&lt;br /&gt;
  typedef odb::result&amp;lt;product&amp;gt; result;&lt;br /&gt;
  typedef odb::query&amp;lt;product&amp;gt; query;&lt;br /&gt;
  result r (db.query&amp;lt;product&amp;gt; (query::category = “beverages”));&lt;br /&gt;
  copy (r.begin (), r.end (), ostream_iterator&amp;lt;price&amp;gt; (cout, &amp;quot;\n&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
  coke.unitPrice (coke.unitPrice () - 0.50);&lt;br /&gt;
  db.update (coke);&lt;br /&gt;
&lt;br /&gt;
  t.commit ();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Anito for .NET===&lt;br /&gt;
Example adapted from [http://anito.codeplex.com/wikipage?title=Quick%20Start%20Tutorial&amp;amp;referringTitle=Home anito.NET]&lt;br /&gt;
&lt;br /&gt;
First, we instantiate a DataSession&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// provider for MS-SQL&lt;br /&gt;
Anito.Data.SqlClient.SqlProvider provider = new Anito.Data.SqlClient.SqlProvider();&lt;br /&gt;
provider.ConnectionString = &amp;quot;ConnectionString&amp;quot;;&lt;br /&gt;
ISession session = new DataSession(provider);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To insert data into our new database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product product = new Product();&lt;br /&gt;
product.ProductCode = &amp;quot;ENT00001&amp;quot;;&lt;br /&gt;
product.Name = &amp;quot;Coke&amp;quot;;&lt;br /&gt;
product.Category = “beverages”;&lt;br /&gt;
product.UnitPrice = “0.99”;&lt;br /&gt;
session.Insert&amp;lt;Product&amp;gt;(product);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update a row&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product product = session.GetT&amp;lt;Product&amp;gt;(p =&amp;gt; p.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
product.Name = &amp;quot;Coca-Cola&amp;quot;;&lt;br /&gt;
session.Update&amp;lt;Product&amp;gt;(product, x =&amp;gt; x.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assuming that Product is an anito mapped object. We can perform a Select query several ways&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Get by key&lt;br /&gt;
Product product1 = session.GetT&amp;lt;Product&amp;gt;(&amp;quot;PRD-000123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
//Get by expression&lt;br /&gt;
Product product2 = session.GetT&amp;lt;Product&amp;gt;(x =&amp;gt; x.ProductCode == &amp;quot;PRD-000123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
//List&lt;br /&gt;
List&amp;lt;Product&amp;gt; list1 = session.GetList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
List&amp;lt;Product&amp;gt; list2 = session.GetList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;(p =&amp;gt; p.ID &amp;lt; 100);&lt;br /&gt;
&lt;br /&gt;
//Paged&lt;br /&gt;
List&amp;lt;Product&amp;gt; pagedList = session.GetPagedList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;(10, 3);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To remove data from a table we run the Delete command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
session.Delete&amp;lt;Entity&amp;gt;(p =&amp;gt; p.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LINQ to SQL for C#===&lt;br /&gt;
&lt;br /&gt;
The query we are from above, in C#, is as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var results = database.Products.Where(product =&amp;gt; product.Category.CategoryName == &amp;quot;Beverages&amp;quot;)&lt;br /&gt;
                              .Select(product =&amp;gt; new&lt;br /&gt;
                                                     {&lt;br /&gt;
                                                         product.ProductName,&lt;br /&gt;
                                                         product.UnitPrice&lt;br /&gt;
                                                     });&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
There is more than one mechanism for implementing ORM in C#. One of the easiest ways is to create models in C# from SQL schemas is to use Visual Studio (http://www.microsoft.com/visualstudio/eng/launch-day). Using this method requires  SQL Server  be installed.&lt;br /&gt;
&lt;br /&gt;
In order to complete this query, mapping between the SQL databases, tables and fields and C# object models must be created. The first step is to set up a data connection to the database you are trying to use to create the model. Once the connection has been established, you need to create a “LINQ to SQL Classes” item in the project. Once the item is created, this creates a [DBName].dbml (for our example, we will call the DB 'Store') file and the O/R designer is opened. From here, you can drag  and drop the tables of interest into to O/R designer. Going back to the Product/Category example, there should be two boxes (one for each table) and an arrow in between showing the relation between the two tables (in our case, one-to-many).&lt;br /&gt;
&lt;br /&gt;
Once this is done, the object models have been created and the designer has automatically generated classes to represent records in the tables of interest. In the Product/Category example, the following classes would be generated with the following information:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Table(Name = &amp;quot;dbo.Categories&amp;quot;)]&lt;br /&gt;
public partial class Category : INotifyPropertyChanging, INotifyPropertyChanged&lt;br /&gt;
{&lt;br /&gt;
   private int _CategoryID;&lt;br /&gt;
   private EntitySet&amp;lt;Product&amp;gt; _Products;&lt;br /&gt;
&lt;br /&gt;
   [Column(Storage = &amp;quot;_CategoryID&amp;quot;, AutoSync = AutoSync.OnInsert,&lt;br /&gt;
       DbType = &amp;quot;Int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true)]&lt;br /&gt;
   public int CategoryID&lt;br /&gt;
   {get&lt;br /&gt;
       { return this._CategoryID; }&lt;br /&gt;
       set&lt;br /&gt;
       { if ((this._CategoryID != value))&lt;br /&gt;
           {&lt;br /&gt;
               this.OnCategoryIDChanging(value);&lt;br /&gt;
               this.SendPropertyChanging();&lt;br /&gt;
               this._CategoryID = value;&lt;br /&gt;
               this.SendPropertyChanged(&amp;quot;CategoryID&amp;quot;);&lt;br /&gt;
               this.OnCategoryIDChanged();&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;b&amp;gt;Category class:&amp;lt;/b&amp;gt; represents each record in Categories table;&lt;br /&gt;
        &amp;lt;b&amp;gt;CategoryID property (an int)&amp;lt;/b&amp;gt;: represents the CategoryID field; So are the other properties shown above;&lt;br /&gt;
        &amp;lt;b&amp;gt;Products property (a collection of Product object):&amp;lt;/b&amp;gt; represents the associated many records in Products table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Table(Name = &amp;quot;dbo.Products&amp;quot;)]&lt;br /&gt;
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged&lt;br /&gt;
{&lt;br /&gt;
   private int _ProductID;&lt;br /&gt;
   private Entity&amp;lt;Category&amp;gt; _Category;&lt;br /&gt;
&lt;br /&gt;
   [Column(Storage = &amp;quot;_ProductID&amp;quot;, AutoSync = AutoSync.OnInsert,&lt;br /&gt;
       DbType = &amp;quot;Int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true)]&lt;br /&gt;
   public int ProductID&lt;br /&gt;
   {get&lt;br /&gt;
       { return this._ProductID; }&lt;br /&gt;
       set&lt;br /&gt;
       { if ((this._ProductID != value))&lt;br /&gt;
           {&lt;br /&gt;
               this.OnProductIDChanging(value);&lt;br /&gt;
               this.SendPropertyChanging();&lt;br /&gt;
               this._ProdcutID = value;&lt;br /&gt;
               this.SendPropertyChanged(&amp;quot;ProductID&amp;quot;);&lt;br /&gt;
               this.OnProductIDChanged();&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;b&amp;gt;Product class&amp;lt;/b&amp;gt;: represents each record in Products table;&lt;br /&gt;
         &amp;lt;b&amp;gt;ProductID property (an int):&amp;lt;/b&amp;gt; represents the ProductID field; So are the other properties shown above;&lt;br /&gt;
         &amp;lt;b&amp;gt;Category property (a Category object):&amp;lt;/b&amp;gt; represents the associated one records in Products table, and;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Database(Name = &amp;quot;Store&amp;quot;)]&lt;br /&gt;
public partial class StoreDataContext : DataContext&lt;br /&gt;
{ public Table&amp;lt;Category&amp;gt; Categories&lt;br /&gt;
   {get&lt;br /&gt;
       { return this.GetTable&amp;lt;Category&amp;gt;(); }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   public Table&amp;lt;Product&amp;gt; Products&lt;br /&gt;
   { get&lt;br /&gt;
       { return this.GetTable&amp;lt;Product&amp;gt;(); }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;b&amp;gt;StoreDataContext class: represents the database;&lt;br /&gt;
        &amp;lt;b&amp;gt;Categories property (a collection of the Category objects):&amp;lt;/b&amp;gt; represents the Categories table;&lt;br /&gt;
       &amp;lt;b&amp;gt; Products property (a collection of the Product objects)&amp;lt;/b&amp;gt;: represents the Products table;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The next step is to map the SQL representations to the C# representations. If you view the Store.dbml file generated by Visual Studio, you will see that is is an XML file. This XML file contains the SQL to C# mappings. There is also a Store.dbml.layout file which outlines how the designer should visualize the object models. Finally, a Store.designer.cs file is created that contains the C# “partials” that were generated.&lt;br /&gt;
&lt;br /&gt;
If needed, the mappings can be easily customized in the designer as well. Any modifications made in the designer are automatically made in the XML files / C# code. The final mapping is a one way mapping: from SQL Server to C#.&lt;br /&gt;
&lt;br /&gt;
It is also possible to do the same thing on the command line using SQLMetal. With SQLMetal, you can do a number of things, including creating the .dbml file created by the Visual Studio designer. The command to run SQLMetal is sqlmetal [options] [&amp;lt;input file&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
=== Java Persistence API ===&lt;br /&gt;
&lt;br /&gt;
The Java Persistence API can be used for object-relational mapping  in Java. It is POJO-based, meaning it is based solely on plain-old Java objects (POJO). This API uses “entities” that are written as POJOs and marked using the  @Entity annotation. An entity is a persistence domain object that represents a table in a relational database. An entity of our Category table would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Entity&lt;br /&gt;
  @Table (name=&amp;quot;Category&amp;quot;)&lt;br /&gt;
  public class Category implements Serializable {&lt;br /&gt;
     @Id&lt;br /&gt;
     @Column(name=&amp;quot;id&amp;quot;, nullable=false)&lt;br /&gt;
     private String CategoryId;&lt;br /&gt;
     @Column(name=&amp;quot;name&amp;quot;)&lt;br /&gt;
     private String CategoryName;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class would also include getters and setters for the various fields. The @Table annotation denotes the database table represented by the entity however if the table and entity name is the same, there is no need for the @Table annotation. The @Column annotation denotes the database column that corresponds to the property/field. The naming assumption applies here as well.&lt;br /&gt;
&lt;br /&gt;
The @ID annotation is used to mark a field/property as a primary key. For our ongoing example, it would something look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     @Id&lt;br /&gt;
     public String getCategoryId() {&lt;br /&gt;
        return this.deptId;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setCategoryId(String deptId) {&lt;br /&gt;
        this.deptId = deptId;&lt;br /&gt;
     }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
Entity state can be represented using embedded classes; these do not have persistent objects of their own.&lt;br /&gt;
&lt;br /&gt;
Depicting relationships has become easier with the Java Persistence API; annotations are used that can specify multiplicity as well as relationship direction. In our ongoing examples, we can implement a many-to-one relationship as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Entity&lt;br /&gt;
  public class Product implements Serializable {&lt;br /&gt;
&lt;br /&gt;
     private Category category;&lt;br /&gt;
     @ManyToOne&lt;br /&gt;
     public Category getCategory() {&lt;br /&gt;
        return Category;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setCategory (Category category){&lt;br /&gt;
        this.category = category;&lt;br /&gt;
     }&lt;br /&gt;
     .........&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  @Entity&lt;br /&gt;
  @Table (name=&amp;quot;Category&amp;quot;)&lt;br /&gt;
  public class Category implements Serializable {&lt;br /&gt;
     .........&lt;br /&gt;
     private Collection&amp;lt;Product&amp;gt; products = new HashSet();&lt;br /&gt;
     .........&lt;br /&gt;
     @OneToMany(mappedBy=&amp;quot;category&amp;quot;, fetch=FetchType.EAGER)&lt;br /&gt;
     public Collection&amp;lt;Product&amp;gt; getProducts() {&lt;br /&gt;
        return products;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setProducts(Collection&amp;lt;Product&amp;gt; products) {&lt;br /&gt;
        this.products = products;&lt;br /&gt;
     }&lt;br /&gt;
     .........&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
If there were a bidirectional relationship between Product and Category, the element mappedBy could be used when specifying multiplicity in the relationship's inverse side by pointing to the name of the property/field that owns the relationship.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Depending on what language you plan to use for your application will dictate what extensions and tools you will use.  If you are driven by cost, then some of the choices are obvious to remove, otherwise you might be driven by you familiarity with a particular language or existing tool set.  Either way one can see how all of the languages have attempted to simplify the process of accessing data in an external datastore.  There is no clear victor in these comparisons, and we should believe the situation will dictate which language to use.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch2_2b next article for which the link does not exist yet], we will look at another style of metaprogramming, CRC Cards, one of the simplest methods of doing object oriented design.  These cards are a way to capture the initial relationships between objects for a given system.  CRC cards will help determine the evolution of these relationships before any code is written.  You can learn very quickly about CRC cards by taking a close look at the software used to create CRC cards, and other artifacts of o-o design.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks Comparison of web application frameworks]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software List of object-relational mapping software (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord Ruby (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework (Wikipedia.org)]&lt;br /&gt;
#[http://ruby-doc.org/docs/ProgrammingRuby/ Programming Ruby - The Pragmatic Programmer's Guide]&lt;br /&gt;
#[http://www.ruby-lang.org/en/about/ Ruby – A Programmers Best Friend]&lt;br /&gt;
#[http://www.djangoproject.com/ Django Project (Djangoproject.com)]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/e80y5yhx%28v=VS.71%29.aspx ADO.NET (Micorsoft.com)]&lt;br /&gt;
#[http://developer.apple.com/legacy/mac/library/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/EnterpriseObjects/DevGuide/EOFDevGuide.pdf Enterprise Objects Framework (Apple.com)]&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w10_pk&amp;diff=64271</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w10 pk</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w10_pk&amp;diff=64271"/>
		<updated>2012-09-14T03:11:46Z</updated>

		<summary type="html">&lt;p&gt;Bijohnso: /* Programming using Language Extensions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2012/ch1_1w25 previous article for which the link does not exist yet], we learn that [http://en.wikipedia.org/wiki/Metaprogramming metaprogramming] is where the computer code interacts with other programs as data and performs many of these interactions at compile time rather than runtime.  This built-in interaction allows the programmers to take advantage of these capabilities and focus their time on the rest of their program logic instead of the details of some of the lower level coding.  In this article, we will take a closer look at one of the styles of metaprogramming referred to as language extensions for [http://en.wikipedia.org/wiki/Object-relational_mapping object-relational mapping] through examples and some comparisons of language extensions and tools.&lt;br /&gt;
&lt;br /&gt;
==Object-Relational Mapping==&lt;br /&gt;
Object-Relational Mapping (ORM) is a methodology for managing data between object oriented systems and relational databases.  The premise of the concept is to provide a universal method to access data in a database.  This is beneficial for all programming languages that can use objects to store and retrieve data from the database.  There are many languages that are using ORM as a technique to manage database data.  In the rest of the article, we will discuss ORM and some of the languages in use today.&lt;br /&gt;
&lt;br /&gt;
==Language Extensions==&lt;br /&gt;
Language extensions for ORM have often been traditionally classified as design patterns or software tools used to perform basic [http://en.wikipedia.org/wiki/Create,_read,_update_and_delete create, read, update and delete (C.R.U.D.)] operations on relational databases, that is, until recent new approaches such as [http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord] have grown in popularity.  ActiveRecord is not just a design pattern it is an increase of function to the active record pattern approach by adding [http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29 inheritance] and [http://en.wikipedia.org/wiki/Association_%28object-oriented_programming%29 associations].  Examining ActiveRecord and other language extensions will allow for comparisons of the ease of programming using these language extensions verses the conventional database oriented systems approach.&lt;br /&gt;
&lt;br /&gt;
==Ruby and ActiveRecord==&lt;br /&gt;
All too often programmers are faced with the challenge of persisting objects from their program into a datastore.  Custom code is created for this purpose that can be complex or difficult for others to understand as well as not seem natural.  Applications that are designed to persist data have the need to know how the objects correspond to the information stored in these database tables.  [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails], first released in 2005, is able to provide a uniform method to help resolve these complicated issues without sacrificing function or knowledge of these objects by using ActiveRecord (AR).  AR is a persistence engine that comes as part of Ruby on Rails.  &amp;quot;''It creates a 'persistable' domain model from business objects and database tables, where logic and data are presented as a unified package''&amp;quot; [http://en.wikipedia.org/wiki/ActiveRecord#Ruby 3].  AR is admired for its simplistic and elegant approach of removing these levels of complexity.  It allows for a 'pluggable' solution to many different popular databases available today to include: [http://en.wikipedia.org/wiki/MySQL MySQL], [http://en.wikipedia.org/wiki/SQLite SQLite], [http://en.wikipedia.org/wiki/Microsoft_SQL_Server SQL Server], [http://en.wikipedia.org/wiki/PostgreSQL PostgreSQL], and [http://en.wikipedia.org/wiki/Oracle_Database Oracle].  &lt;br /&gt;
&lt;br /&gt;
ActiveRecord uses a [http://en.wikipedia.org/wiki/Single_Table_Inheritance Single Table Inheritance] to allow for inheritance capabilities and provides a set of macros for association relationships between classes of objects, such as belongs_to, has_one, has_many, etc.  AR is not only a component of the [http://en.wikipedia.org/wiki/Model-view-controller Model view-controller (MVC)] for Ruby on Rails but it is also a standalone ORM package for Ruby itself.  Ruby, Ruby on Rails, and ActiveRecord continue to grow in popularity due to not only the curiosity of programmers but their ability to improve function and feature sets while maintaining the initial intent of the language, &amp;quot;''trying to make Ruby natural, not simple''&amp;quot; -- Yukihiro “matz” Matsumoto [http://www.ruby-lang.org/en/about/ 8].  Other languages have been able to learn from AR and have tried to add this capability for themselves.  Let’s take a closer look at some other implementations that attempts to duplicate AR’s elegance.&lt;br /&gt;
&lt;br /&gt;
==Other Examples of Language Extensions==&lt;br /&gt;
===ADO.NET Entity Framework===&lt;br /&gt;
[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework], Microsoft's ORM, part of [http://en.wikipedia.org/wiki/.NET_Framework .NET] 4.0 was first developed in 2008.  The Entity Framework tries to remove ORM mismatches that often plague conventional database oriented programs by using an Entity data model (EDM) and an Entity-Relationship data model to define the Relationships associated to each Entity.  The EDM consists of a schema and a mapping specification.  The schema defines the data types from the entities and the mapping provides the connections between the database scheme and the conceptual scheme. The Entity Framework has its own version of a query language called Entity SQL which continues to focus only on the conceptual entities and relationships as opposed to the actual database.  It works with many popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.&lt;br /&gt;
&lt;br /&gt;
===Django===&lt;br /&gt;
Python, presents an interesting case because it is an extremely similar language to Ruby in syntax and somewhat in philosophy. &lt;br /&gt;
[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django], is an ORM included in Django open source framework for Python.  It follows a MVC [http://en.wikipedia.org/wiki/Architectural_pattern_%28computer_science%29 architectural pattern] and was originally released in 2005 with the primary goal of making complex, database driven websites easier to create and maintain.  Instilled in its principles are emphasis on loose coupling, rapid development, [http://en.wikipedia.org/wiki/Don%27t_repeat_yourself don’t repeat yourself], and reusability (a.k.a. less code).  The basis of its design is to encapsulate objects just like the ActiveRecord design pattern in models so that all the information needed can be stored in the model and knowledge of the database is not exposed. Django can essentially be considered the equivalent to Rails for Ruby.&lt;br /&gt;
&lt;br /&gt;
===Enterprise Objects Framework===&lt;br /&gt;
Lastly we will introduce [http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework (EOF)], Mac OS X/Java, part of Apple [http://en.wikipedia.org/wiki/WebObjects WebObjects].  EOF is the oldest of the bunch, introduced in 1994 for a product call [http://en.wikipedia.org/wiki/NeXTSTEP NeXTSTEP].  It was indented to eliminate the interaction with the [http://en.wikipedia.org/wiki/Relational_database relational database] and the Java or Objective-C objects.  EOF was later integrated into WebObjects.  An EOFModel contains the mappings from the database to the classes, class attributes, and objects.  EOF also incorporates inheritance into its feature set to allow a more object oriented approach using Enterprise Objects to reflect the hierarchy.  EOF uses [http://en.wikipedia.org/wiki/Jdbc Java Database Connectivity (JDBC)] and [http://en.wikipedia.org/wiki/JNDI Java Naming and Directory Interface (JNDI)] to talk to databases that support that, such as Oracle, DB2, and MySQL.&lt;br /&gt;
===Java's Hibernate===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate] is Java’s ORM framework library that maps Java classes to database tables and provides data query and retrieval functionality via XML mappings done though Java Annotations configurations. In addition, it can generate SQL calls that lessen the need for developers to convert result sets into objects manually.&lt;br /&gt;
One of the first things that Hibernate uses for any interactions is a Session Factory class which is designed as a [http://en.wikipedia.org/wiki/Factory_method_pattern class factory] to return the current Hibernate session object and ensure that only one instance of the session be issued per thread. Without listing the actual code of the Session Factory the code basically allows for getting the session object, opening the session for use, and closing the session after use.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, Hibernate database table creation can only be done manually using separate tools or additional Java code. This is a prime example of the additional knowledge a developer must have to correctly create a hibernate project. A developer must know that each object type must have its own table and that the fields within the table must correspond to the types of the object’s member variables.&lt;br /&gt;
&lt;br /&gt;
Based on the tables created, classes must then be created with the member variables and setters/getters associated with the field types created in the database. For example, if the database table contains a field 'name' which is of type varchar and limited to 255 characters, the setter/getter must be of type String and the coder (if they wish) may limit the entry in the setter to 255 characters.&lt;br /&gt;
&lt;br /&gt;
The next step is to create a Hibernate configuration file which essentially defines the database connection including the url, username, database type, password, etc. After this, the developer must explicitly tell Hibernate the relationships between the member variables of the class and the fields of the database with either an xml file or using Java annotations inside of the class. This is yet another example of the extra effort that has to be taken by the developer, but which also gives the developer great power and flexibility to name the fields and member variables different things.&lt;br /&gt;
&lt;br /&gt;
===JazzRecord for JavaScript===&lt;br /&gt;
&lt;br /&gt;
JavaScript presents another good case study for the use of ORM and ActiveRecord in application development. For one, JavaScript, like Python and Ruby, is loosely typed which can make dealing with the strictness of database typing an interesting challenge for these languages. Secondly, JazzRecord was modeled specifically after ActiveRecord in Ruby but does have its own differences.&lt;br /&gt;
&lt;br /&gt;
==Programming using Language Extensions==&lt;br /&gt;
Several language extensions have been introduced in previous sections of the article.  &lt;br /&gt;
Let's take a closer look at a specific scenario and show how each of them would implement their respective table for multiple language packages. In some of the examples below you will see that many of the language extensions require external tools to generate the hooks in to the language.&lt;br /&gt;
&lt;br /&gt;
To illustrate the differences in implementation of ORM in different language packages, we will use the following example: &lt;br /&gt;
'''Products and Categories.''' &lt;br /&gt;
&lt;br /&gt;
A Category can have many Products but a Product can only have one Category. A sample query would be &lt;br /&gt;
&amp;lt;pre&amp;gt;SELECT product.productName &amp;amp; product.unitPrice FROM Products WHERE product.category.categoryName = “Beverages” &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ActiveRecord===&lt;br /&gt;
For ActiveRecord in Ruby on Rails, the syntax to create the table is contained within the Product class that inherits from the ActiveRecord class.  No external tools are required to generate the Ruby code, only the Ruby interpreter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :product do |p|&lt;br /&gt;
      p.string :name&lt;br /&gt;
      p.string :id&lt;br /&gt;
      p.string :category&lt;br /&gt;
      p.float :unitPrice&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :product&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now create a new Product in Ruby, update the attributes, and save the object.  The .save method will actually update the database table. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
n = Product.new&lt;br /&gt;
n.id = &amp;quot;1&amp;quot;&lt;br /&gt;
n.name = &amp;quot;Coke&amp;quot;&lt;br /&gt;
n.category = &amp;quot;beverage&amp;quot;&lt;br /&gt;
n.unitPrice = 0.99&lt;br /&gt;
n.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ADO.NET Entity Framework===&lt;br /&gt;
&lt;br /&gt;
ADO.NET requires that you use the [http://msdn.microsoft.com/en-us/library/bb738483.aspx Entity Model Designer] which is part of [http://msdn.microsoft.com/en-us/vstudio/default.aspx Microsoft Visual Studio].  The Designer allows you to create your model which includes any entities and associations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Designer will ultimately generate an XML file that represents the Entity Data Model.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- A snippit from the xml file – shows the Product definion --&amp;gt;&lt;br /&gt;
&amp;lt;!-- There are not associations in out example --&amp;gt;&lt;br /&gt;
&amp;lt;EntityType Name = &amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Name&amp;quot; Type = &amp;quot;String&amp;quot; /&amp;gt; &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Category&amp;quot; Type = &amp;quot;String&amp;quot; /&amp;gt; &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;Unit Price&amp;quot; Type = &amp;quot;Float&amp;quot; /&amp;gt;           &lt;br /&gt;
     &amp;lt;Property Name = &amp;quot;id&amp;quot; Type = &amp;quot;String&amp;quot; Nullable = &amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/EntityType&amp;gt;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In code for the Product object, the setter on the class would look something like this.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set&lt;br /&gt;
{&lt;br /&gt;
   this.CategoryReference.EntityKey = new EntityKey(&amp;quot;ProductEntities.Category&amp;quot;, &amp;quot;id&amp;quot;, &amp;quot;name&amp;quot;, &amp;quot;unitPrice&amp;quot;, &amp;quot;category&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Django===&lt;br /&gt;
&lt;br /&gt;
In Django, a model is defined to represent a product. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  from django.db import models&lt;br /&gt;
  class Product(models.Model):&lt;br /&gt;
    name= models.CharField(max_length=200)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After creating a model for a product it will generate a corresponding table.&lt;br /&gt;
Note that &amp;quot;id&amp;quot; is included as part of the model, so this might cause some unexpected issues if you planned to use id differently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  BEGIN;&lt;br /&gt;
  CREATE TABLE myapp_product (&lt;br /&gt;
    &amp;quot;id&amp;quot; serial NOT NULL PRIMARY KEY,&lt;br /&gt;
          &amp;quot;name&amp;quot; varchar(200),&lt;br /&gt;
          &amp;quot;category&amp;quot; varchar(200),&lt;br /&gt;
          &amp;quot;unitPrice&amp;quot; decimal&lt;br /&gt;
  );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a new instance of a Product and save it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
p =  Product(name='Coke', category='beverage', unitPrice=0.99)&lt;br /&gt;
p.save()&lt;br /&gt;
p.id     # Returns the ID of your new object.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enterprise Objects Framework===&lt;br /&gt;
The biggest downside with EOF and WebObjects is that it is not free.  The Server and development environment is fairly expensive.  However, here is a quick look at how you would create an EOF model that represents the classes, attributes and the objects.&lt;br /&gt;
&lt;br /&gt;
To generate the Product definition developers must use the [http://www.mactech.com/articles/mactech/Vol.16/16.10/BuildanEOModel/index.html EOModeler UI].&lt;br /&gt;
&lt;br /&gt;
The code to create a new instance / database entry is fairly intuitive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   EOEditingContext ep =  new EOEditingContext();&lt;br /&gt;
&lt;br /&gt;
   Product p =  new Product();&lt;br /&gt;
   p.id = &amp;quot;1&amp;quot;;&lt;br /&gt;
   p.name = &amp;quot;Coke&amp;quot;;&lt;br /&gt;
   p.category = &amp;quot;beverage&amp;quot;;&lt;br /&gt;
   p.unitPrice = 0.99;&lt;br /&gt;
 &lt;br /&gt;
   ep.add(p);&lt;br /&gt;
   ep.saveChanges();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java Hibernate===&lt;br /&gt;
There is no question that the set up effort involved in getting a Hibernate project going is substantially more than in ActiveRecord for Rails. The actual code to create and manipulate the objects is approximately the same between the two languages. This is clearly a case where more power is given to the developer but it is not without cost, which in this case is a fairly complex and involved list of set up steps.&lt;br /&gt;
&lt;br /&gt;
Below is an example set up for a Hibernate transaction&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product p = new Product();&lt;br /&gt;
p.name(&amp;quot;Coke&amp;quot;);&lt;br /&gt;
p.category(&amp;quot;Beverage&amp;quot;);&lt;br /&gt;
p.unitPrice(0.99)&lt;br /&gt;
&lt;br /&gt;
Transaction tx = null;&lt;br /&gt;
Session s1 = SessionFactory.getInstance().getCurrentSession();&lt;br /&gt;
try &lt;br /&gt;
{&lt;br /&gt;
   tx = session.beginTransaction();&lt;br /&gt;
   s1.save(p);&lt;br /&gt;
   tx.commit();&lt;br /&gt;
}&lt;br /&gt;
catch(RuntimeException e) &lt;br /&gt;
{&lt;br /&gt;
   tx.rollback();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===JStORM for Javascript===&lt;br /&gt;
Example adapted from [http://ajaxian.com/archives/jstorm-a-new-javascript-object-relational-mapper Ajaxian]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
JStORM is very similar to Rails in which we define a Model that will hold our Products&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var Product = new JStORM.Model({&lt;br /&gt;
  name:&amp;quot;Product&amp;quot;, // the first argument is the table name to use in the db.&lt;br /&gt;
  fields: { // the second argument is an object that defines the table columns&lt;br /&gt;
// the keys are the column names and the values are the column types (limited to Integer,Float,TimeStamp and String)&lt;br /&gt;
// The additional sql properties can be defined: notNull, defaultValue, maxLength, unique&lt;br /&gt;
     productName:new JStORM.Field({type:&amp;quot;String&amp;quot;,maxLength:25}),&lt;br /&gt;
     category:new JStORM.Field({type:&amp;quot;String&amp;quot;, maxLength:25}),&lt;br /&gt;
     unitPrice:new JStORM.Field({type:&amp;quot;Float&amp;quot;}),&lt;br /&gt;
  },&lt;br /&gt;
  connection:&amp;quot;default&amp;quot;&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basic SQL operations are one line code statements&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product.createTable(); // creates the table&lt;br /&gt;
Product.insert([&amp;quot;Coke&amp;quot;,&amp;quot;beverages&amp;quot;]); // insert Coke beverage into Product table&lt;br /&gt;
Product.insert([&amp;quot;PBR&amp;quot;,&amp;quot;beverages&amp;quot;]); // insert PBR&lt;br /&gt;
Product.select(&amp;quot;category = 'beverages'&amp;quot;) // selects products of category beverages&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Jazz Record for Javascript===&lt;br /&gt;
Declaring a model in JazzRecord is very similar to ActiveRecord in structure, where the types of each of the fields must be explicitly identified so that the correct table can be created.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var Products = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;products&amp;quot;,&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;Coke&amp;quot;,&lt;br /&gt;
    category: &amp;quot;beverage&amp;quot;,&lt;br /&gt;
    unitPrice: 0.99&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Like ActiveRecord, retrieving objects from the database is effortless and very transparent. Here is an example of querying a few objects and then using those objects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var product1 = Products.findBy(&amp;quot;name&amp;quot;, &amp;quot;Coke&amp;quot;);&lt;br /&gt;
var product2 = Products.findBy(&amp;quot;category&amp;quot;, &amp;quot;beverage&amp;quot;);&lt;br /&gt;
var sameProduct = (product.name == product2.name);&lt;br /&gt;
product2.name = &amp;quot;NewProduct&amp;quot;;&lt;br /&gt;
product2.save();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The JazzRecord team even decided to follow ActiveRecord in including the ability to identify associations between the different models. The following is an example of how to define associations between two models:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//new version of JazzLegend model&lt;br /&gt;
Category = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;categories&amp;quot;,&lt;br /&gt;
  foreignKey: &amp;quot;product_id&amp;quot;,&lt;br /&gt;
  hasMany: {products: &amp;quot;products&amp;quot;},&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;beverage&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
//associated model&lt;br /&gt;
Product = new JazzRecord.Model({&lt;br /&gt;
  table: &amp;quot;products&amp;quot;,&lt;br /&gt;
  belongsTo: {category: &amp;quot;categories&amp;quot;},&lt;br /&gt;
  columns: {&lt;br /&gt;
    name: &amp;quot;text&amp;quot;,&lt;br /&gt;
    unitPrice: 0.99,&lt;br /&gt;
    category_id: &amp;quot;1&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ODB for C++===&lt;br /&gt;
Example adapted from [http://www.codesynthesis.com/products/odb/ Code Synthesis]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #pragma db object&lt;br /&gt;
  class product&lt;br /&gt;
  {&lt;br /&gt;
    ...&lt;br /&gt;
  private:&lt;br /&gt;
    product ();&lt;br /&gt;
&lt;br /&gt;
    #pragma db id auto&lt;br /&gt;
    unsigned long id_;&lt;br /&gt;
&lt;br /&gt;
    string productName_;&lt;br /&gt;
    string category_;&lt;br /&gt;
    float unitPrice_;&lt;br /&gt;
  };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Given the above declarations, we can perform various database operations with objects of the product class:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 product coke (&amp;quot;Coca-Cola&amp;quot;, “beverages”, 0.99);&lt;br /&gt;
 product pbr (&amp;quot;Pabst Blue Ribbon&amp;quot;, “beverages”, 1.99);&lt;br /&gt;
 odb::transaction t (db.begin ());&lt;br /&gt;
db.persist (coke);&lt;br /&gt;
db.persist (pbr);&lt;br /&gt;
&lt;br /&gt;
  typedef odb::result&amp;lt;product&amp;gt; result;&lt;br /&gt;
  typedef odb::query&amp;lt;product&amp;gt; query;&lt;br /&gt;
  result r (db.query&amp;lt;product&amp;gt; (query::category = “beverages”));&lt;br /&gt;
  copy (r.begin (), r.end (), ostream_iterator&amp;lt;price&amp;gt; (cout, &amp;quot;\n&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
  coke.unitPrice (coke.unitPrice () - 0.50);&lt;br /&gt;
  db.update (coke);&lt;br /&gt;
&lt;br /&gt;
  t.commit ();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Anito for .NET===&lt;br /&gt;
Example adapted from [http://anito.codeplex.com/wikipage?title=Quick%20Start%20Tutorial&amp;amp;referringTitle=Home anito.NET]&lt;br /&gt;
&lt;br /&gt;
First, we instantiate a DataSession&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// provider for MS-SQL&lt;br /&gt;
Anito.Data.SqlClient.SqlProvider provider = new Anito.Data.SqlClient.SqlProvider();&lt;br /&gt;
provider.ConnectionString = &amp;quot;ConnectionString&amp;quot;;&lt;br /&gt;
ISession session = new DataSession(provider);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To insert data into our new database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product product = new Product();&lt;br /&gt;
product.ProductCode = &amp;quot;ENT00001&amp;quot;;&lt;br /&gt;
product.Name = &amp;quot;Coke&amp;quot;;&lt;br /&gt;
product.Category = “beverages”;&lt;br /&gt;
product.UnitPrice = “0.99”;&lt;br /&gt;
session.Insert&amp;lt;Product&amp;gt;(product);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update a row&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Product product = session.GetT&amp;lt;Product&amp;gt;(p =&amp;gt; p.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
product.Name = &amp;quot;Coca-Cola&amp;quot;;&lt;br /&gt;
session.Update&amp;lt;Product&amp;gt;(product, x =&amp;gt; x.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assuming that Product is an anito mapped object. We can perform a Select query several ways&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Get by key&lt;br /&gt;
Product product1 = session.GetT&amp;lt;Product&amp;gt;(&amp;quot;PRD-000123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
//Get by expression&lt;br /&gt;
Product product2 = session.GetT&amp;lt;Product&amp;gt;(x =&amp;gt; x.ProductCode == &amp;quot;PRD-000123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
//List&lt;br /&gt;
List&amp;lt;Product&amp;gt; list1 = session.GetList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
List&amp;lt;Product&amp;gt; list2 = session.GetList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;(p =&amp;gt; p.ID &amp;lt; 100);&lt;br /&gt;
&lt;br /&gt;
//Paged&lt;br /&gt;
List&amp;lt;Product&amp;gt; pagedList = session.GetPagedList&amp;lt;List&amp;lt;Product&amp;gt;, Product&amp;gt;(10, 3);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To remove data from a table we run the Delete command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
session.Delete&amp;lt;Entity&amp;gt;(p =&amp;gt; p.ProductCode == &amp;quot;ENT00001&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LINQ to SQL for C#===&lt;br /&gt;
&lt;br /&gt;
The query we are from above, in C#, is as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var results = database.Products.Where(product =&amp;gt; product.Category.CategoryName == &amp;quot;Beverages&amp;quot;)&lt;br /&gt;
                              .Select(product =&amp;gt; new&lt;br /&gt;
                                                     {&lt;br /&gt;
                                                         product.ProductName,&lt;br /&gt;
                                                         product.UnitPrice&lt;br /&gt;
                                                     });&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
There is more than one mechanism for implementing ORM in C#. One of the easiest ways is to create models in C# from SQL schemas is to use Visual Studio (http://www.microsoft.com/visualstudio/eng/launch-day). Using this method requires  SQL Server  be installed.&lt;br /&gt;
&lt;br /&gt;
In order to complete this query, mapping between the SQL databases, tables and fields and C# object models must be created. The first step is to set up a data connection to the database you are trying to use to create the model. Once the connection has been established, you need to create a “LINQ to SQL Classes” item in the project. Once the item is created, this creates a [DBName].dbml (for our example, we will call the DB 'Store') file and the O/R designer is opened. From here, you can drag  and drop the tables of interest into to O/R designer. Going back to the Product/Category example, there should be two boxes (one for each table) and an arrow in between showing the relation between the two tables (in our case, one-to-many).&lt;br /&gt;
&lt;br /&gt;
Once this is done, the object models have been created and the designer has automatically generated classes to represent records in the tables of interest. In the Product/Category example, the following classes would be generated with the following information:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Table(Name = &amp;quot;dbo.Categories&amp;quot;)]&lt;br /&gt;
public partial class Category : INotifyPropertyChanging, INotifyPropertyChanged&lt;br /&gt;
{&lt;br /&gt;
   private int _CategoryID;&lt;br /&gt;
   private EntitySet&amp;lt;Product&amp;gt; _Products;&lt;br /&gt;
&lt;br /&gt;
   [Column(Storage = &amp;quot;_CategoryID&amp;quot;, AutoSync = AutoSync.OnInsert,&lt;br /&gt;
       DbType = &amp;quot;Int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true)]&lt;br /&gt;
   public int CategoryID&lt;br /&gt;
   {get&lt;br /&gt;
       { return this._CategoryID; }&lt;br /&gt;
       set&lt;br /&gt;
       { if ((this._CategoryID != value))&lt;br /&gt;
           {&lt;br /&gt;
               this.OnCategoryIDChanging(value);&lt;br /&gt;
               this.SendPropertyChanging();&lt;br /&gt;
               this._CategoryID = value;&lt;br /&gt;
               this.SendPropertyChanged(&amp;quot;CategoryID&amp;quot;);&lt;br /&gt;
               this.OnCategoryIDChanged();&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;b&amp;gt;Category class:&amp;lt;/b&amp;gt; represents each record in Categories table;&lt;br /&gt;
        &amp;lt;b&amp;gt;CategoryID property (an int)&amp;lt;/b&amp;gt;: represents the CategoryID field; So are the other properties shown above;&lt;br /&gt;
        &amp;lt;b&amp;gt;Products property (a collection of Product object):&amp;lt;/b&amp;gt; represents the associated many records in Products table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Table(Name = &amp;quot;dbo.Products&amp;quot;)]&lt;br /&gt;
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged&lt;br /&gt;
{&lt;br /&gt;
   private int _ProductID;&lt;br /&gt;
   private Entity&amp;lt;Category&amp;gt; _Category;&lt;br /&gt;
&lt;br /&gt;
   [Column(Storage = &amp;quot;_ProductID&amp;quot;, AutoSync = AutoSync.OnInsert,&lt;br /&gt;
       DbType = &amp;quot;Int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true)]&lt;br /&gt;
   public int ProductID&lt;br /&gt;
   {get&lt;br /&gt;
       { return this._ProductID; }&lt;br /&gt;
       set&lt;br /&gt;
       { if ((this._ProductID != value))&lt;br /&gt;
           {&lt;br /&gt;
               this.OnProductIDChanging(value);&lt;br /&gt;
               this.SendPropertyChanging();&lt;br /&gt;
               this._ProdcutID = value;&lt;br /&gt;
               this.SendPropertyChanged(&amp;quot;ProductID&amp;quot;);&lt;br /&gt;
               this.OnProductIDChanged();&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;b&amp;gt;Product class: represents each record in Products table;&lt;br /&gt;
         &amp;lt;b&amp;gt;ProductID property (an int):&amp;lt;/b&amp;gt; represents the ProductID field; So are the other properties shown above;&lt;br /&gt;
         &amp;lt;b&amp;gt;Category property (a Category object):&amp;lt;/b&amp;gt; represents the associated one records in Products table, and;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Database(Name = &amp;quot;Store&amp;quot;)]&lt;br /&gt;
public partial class StoreDataContext : DataContext&lt;br /&gt;
{ public Table&amp;lt;Category&amp;gt; Categories&lt;br /&gt;
   {get&lt;br /&gt;
       { return this.GetTable&amp;lt;Category&amp;gt;(); }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   public Table&amp;lt;Product&amp;gt; Products&lt;br /&gt;
   { get&lt;br /&gt;
       { return this.GetTable&amp;lt;Product&amp;gt;(); }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;b&amp;gt;StoreDataContext class: represents the database;&lt;br /&gt;
        &amp;lt;b&amp;gt;Categories property (a collection of the Category objects):&amp;lt;/b&amp;gt; represents the Categories table;&lt;br /&gt;
       &amp;lt;b&amp;gt; Products property (a collection of the Product objects)&amp;lt;/b&amp;gt;: represents the Products table;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The next step is to map the SQL representations to the C# representations. If you view the Store.dbml file generated by Visual Studio, you will see that is is an XML file. This XML file contains the SQL to C# mappings. There is also a Store.dbml.layout file which outlines how the designer should visualize the object models. Finally, a Store.designer.cs file is created that contains the C# “partials” that were generated.&lt;br /&gt;
&lt;br /&gt;
If needed, the mappings can be easily customized in the designer as well. Any modifications made in the designer are automatically made in the XML files / C# code. The final mapping is a one way mapping: from SQL Server to C#.&lt;br /&gt;
&lt;br /&gt;
It is also possible to do the same thing on the command line using SQLMetal. With SQLMetal, you can do a number of things, including creating the .dbml file created by the Visual Studio designer. The command to run SQLMetal is sqlmetal [options] [&amp;lt;input file&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
=== Java Persistence API ===&lt;br /&gt;
&lt;br /&gt;
The Java Persistence API can be used for object-relational mapping  in Java. It is POJO-based, meaning it is based solely on plain-old Java objects (POJO). This API uses “entities” that are written as POJOs and marked using the  @Entity annotation. An entity is a persistence domain object that represents a table in a relational database. An entity of our Category table would look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Entity&lt;br /&gt;
  @Table (name=&amp;quot;Category&amp;quot;)&lt;br /&gt;
  public class Category implements Serializable {&lt;br /&gt;
     @Id&lt;br /&gt;
     @Column(name=&amp;quot;id&amp;quot;, nullable=false)&lt;br /&gt;
     private String CategoryId;&lt;br /&gt;
     @Column(name=&amp;quot;name&amp;quot;)&lt;br /&gt;
     private String CategoryName;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class would also include getters and setters for the various fields. The @Table annotation denotes the database table represented by the entity however if the table and entity name is the same, there is no need for the @Table annotation. The @Column annotation denotes the database column that corresponds to the property/field. The naming assumption applies here as well.&lt;br /&gt;
&lt;br /&gt;
The @ID annotation is used to mark a field/property as a primary key. For our ongoing example, it would something look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     @Id&lt;br /&gt;
     public String getCategoryId() {&lt;br /&gt;
        return this.deptId;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setCategoryId(String deptId) {&lt;br /&gt;
        this.deptId = deptId;&lt;br /&gt;
     }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
Entity state can be represented using embedded classes; these do not have persistent objects of their own.&lt;br /&gt;
&lt;br /&gt;
Depicting relationships has become easier with the Java Persistence API; annotations are used that can specify multiplicity as well as relationship direction. In our ongoing examples, we can implement a many-to-one relationship as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@Entity&lt;br /&gt;
  public class Product implements Serializable {&lt;br /&gt;
&lt;br /&gt;
     private Category category;&lt;br /&gt;
     @ManyToOne&lt;br /&gt;
     public Category getCategory() {&lt;br /&gt;
        return Category;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setCategory (Category category){&lt;br /&gt;
        this.category = category;&lt;br /&gt;
     }&lt;br /&gt;
     .........&lt;br /&gt;
  }&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  @Entity&lt;br /&gt;
  @Table (name=&amp;quot;Category&amp;quot;)&lt;br /&gt;
  public class Category implements Serializable {&lt;br /&gt;
     .........&lt;br /&gt;
     private Collection&amp;lt;Product&amp;gt; products = new HashSet();&lt;br /&gt;
     .........&lt;br /&gt;
     @OneToMany(mappedBy=&amp;quot;category&amp;quot;, fetch=FetchType.EAGER)&lt;br /&gt;
     public Collection&amp;lt;Product&amp;gt; getProducts() {&lt;br /&gt;
        return products;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
     public void setProducts(Collection&amp;lt;Product&amp;gt; products) {&lt;br /&gt;
        this.products = products;&lt;br /&gt;
     }&lt;br /&gt;
     .........&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
If there were a bidirectional relationship between Product and Category, the element mappedBy could be used when specifying multiplicity in the relationship's inverse side by pointing to the name of the property/field that owns the relationship.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Depending on what language you plan to use for your application will dictate what extensions and tools you will use.  If you are driven by cost, then some of the choices are obvious to remove, otherwise you might be driven by you familiarity with a particular language or existing tool set.  Either way one can see how all of the languages have attempted to simplify the process of accessing data in an external datastore.  There is no clear victor in these comparisons, and we should believe the situation will dictate which language to use.&lt;br /&gt;
&lt;br /&gt;
==What’s Next?==&lt;br /&gt;
In the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch2_2b next article for which the link does not exist yet], we will look at another style of metaprogramming, CRC Cards, one of the simplest methods of doing object oriented design.  These cards are a way to capture the initial relationships between objects for a given system.  CRC cards will help determine the evolution of these relationships before any code is written.  You can learn very quickly about CRC cards by taking a close look at the software used to create CRC cards, and other artifacts of o-o design.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks Comparison of web application frameworks]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software List of object-relational mapping software (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord Ruby (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django (Wikipedia.org)]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework (Wikipedia.org)]&lt;br /&gt;
#[http://ruby-doc.org/docs/ProgrammingRuby/ Programming Ruby - The Pragmatic Programmer's Guide]&lt;br /&gt;
#[http://www.ruby-lang.org/en/about/ Ruby – A Programmers Best Friend]&lt;br /&gt;
#[http://www.djangoproject.com/ Django Project (Djangoproject.com)]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/e80y5yhx%28v=VS.71%29.aspx ADO.NET (Micorsoft.com)]&lt;br /&gt;
#[http://developer.apple.com/legacy/mac/library/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/EnterpriseObjects/DevGuide/EOFDevGuide.pdf Enterprise Objects Framework (Apple.com)]&lt;/div&gt;</summary>
		<author><name>Bijohnso</name></author>
	</entry>
</feed>