| ////////////////////////////////////////// |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| ////////////////////////////////////////// |
| |
| = Design patterns in Groovy |
| |
| |
| Using http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29[design patterns] with Java is a well-established topic. Design patterns also apply to Groovy: |
| |
| * some patterns carry over directly (and can make use of normal Groovy syntax improvements for greater readability) |
| * some patterns are no longer required because they are built right into the language or because Groovy supports a better way of achieving the intent of the pattern |
| * some patterns that have to be expressed at the design level in other languages can be implemented directly in Groovy (due to the way Groovy can blur the distinction between design and implementation) |
| |
| == Patterns |
| |
| include::{projectdir}/{specfolder}/design-pattern-abstract-factory.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-adapter.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-bouncer.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-chain-of-responsibility.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-composite.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-decorator.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-delegation.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-flyweight.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-iterator.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-loan-my-resource.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-null-object.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-pimp-my-library.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-proxy.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-singleton.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-state.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-strategy.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-template-method.adoc[leveloffset=+2] |
| |
| include::{projectdir}/{specfolder}/design-pattern-visitor.adoc[leveloffset=+2] |
| |
| == References |
| |
| . Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (1995). _Design Patterns: Elements of Reusable Object-Oriented Software_. Addison-Wesley. ISBN 0-201-63361-2. |
| * _The canonical reference of design patterns._ |
| . Martin Fowler (1999). _Refactoring: Improving the Design of Existing Code_. Addison-Wesley. ISBN 0-201-48567-2. |
| . Joshua Kerievsky (2004). _Refactoring To Patterns_. Addison-Wesley. ISBN 0-321-21335-1. |
| . Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates (2004). _Head First Design Patterns_. O’Reilly. ISBN 0-596-00712-4. |
| *_A great book to read, informative as well as amusing._ |
| . Dierk Koenig with Andrew Glover, Paul King, Guillaume Laforge and Jon Skeet (2007). _Groovy in Action_. Manning. ISBN 1-932394-84-2. |
| * _Discusses Visitor, Builder and other Patterns._ |
| . Brad Appleton (1999). http://www.bradapp.com/docs/pizza-inv.html[Pizza Inversion - a Pattern for Efficient Resource Consumption]. |
| * _One of the most frequently used patterns by many software engineers!_ |
| . _Design Patterns in Dynamic Languages_ by Neil Ford. Houston Java User’s Group. Examples in Groovy and Ruby. http://www.oracle.com/technetwork/server-storage/ts-4961-159222.pdf |