CSC/ECE 517 Fall 2012/ch2b 2w59 bc: Difference between revisions
(→UML) |
|||
Line 8: | Line 8: | ||
===UML=== | ===UML=== | ||
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. | |||
Wikipedia<ref name="wikipedia"/> and dofactory<ref name="dofactory"/> both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers<ref name="javapapers"/> provides an Ice Cream example and Head First Design Patterns<ref name="head_first">https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf</ref> 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. | Wikipedia<ref name="wikipedia"/> and dofactory<ref name="dofactory"/> both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers<ref name="javapapers"/> provides an Ice Cream example and Head First Design Patterns<ref name="head_first">https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf</ref> 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. | ||
Revision as of 20:14, 16 November 2012
Decorator Directory
General Resources
Description of the Pattern
Wikipedia<ref name="wikipedia">http://en.wikipedia.org/wiki/Decorator_pattern</ref> and dofactory<ref name="dofactory">http://www.dofactory.com/Patterns/PatternDecorator.aspx</ref> provide solid explanations of the Decorator Pattern. dofactory<ref name="dofactory"/> is much more concise than Wikipedia<ref name="wikipedia"/>. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia<ref name="wikipedia"/>, 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.
If you understand Java (or a Java like language), javapapers<ref name="javapapers">http://javapapers.com/design-patterns/decorator-pattern/</ref> 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.
UML
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.
Wikipedia<ref name="wikipedia"/> and dofactory<ref name="dofactory"/> both provide UML diagrams of the Decorator Pattern concept. For UML diagrams of concrete examples, javapapers<ref name="javapapers"/> provides an Ice Cream example and Head First Design Patterns<ref name="head_first">https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf</ref> 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.
Ruby
Java & C#
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 "Head First Design Patterns"; in this book an in-depth explanation of the Decorator Pattern can be found <ref name="headfirst">https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf - 2004</ref>. 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 "decorate" 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.
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 "Head First Design Patterns" 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 <ref name="sourcemaking"> http://sourcemaking.com/design_patterns/decorator - 2012? </ref>. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern.
Directory
- Wikipedia - Decorator Pattern
- Pro: Provides background, motivation and a good overview of the pattern, as well as some high level examples.
- Con: Wikipedia can be fairly difficult to follow sometimes and this article is not much of an exception (also, Wikipedia's credibility is debated).
- dofactory - Decorator Design Pattern
- Pro: Provides a quick definition, list of participants and abstract UML diagram.
- Con: Not much of an explanation - just good for referencing.
- javapapers - Decorator Design Pattern (Java)
- Pro: Provides a short overview of the pattern as well as a good concrete example with UML and Java code.
- Con: The concrete example is a good start, but it may not be real-world enough to provide a complete understand.
- Head First Design Patterns
- 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.
- 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.
References
<references/>