在Java中使用设计模式是一个广为大家接受的主题。设计模式同样也适用与Groovy
- 一些模式直接继续使用(并可以利用标准的Groovy语句提升更好的可读性)
- 一些模式不再需要,因为他们已经被内建到语言中了,或者Groovy支持一种更好的方式来达到模式的意图。
- 一些模式在其他语言中必须在设计层面进行表示,但是在Groovy中可以直接实现它(由于Groovy方式可以模糊设计和视线之间的区别)
模式
- Abstract Factory Pattern
- Adapter Pattern
- Bouncer Pattern
- Chain of Responsibility Pattern
- Composite Pattern
- Decorator Pattern
- Delegation Pattern
- Flyweight Pattern
- Iterator Pattern
- Loan my Resource Pattern
- Null Object Pattern
- Pimp my Library Pattern
- Proxy Pattern
- Singleton Pattern
- State Pattern
- Strategy Pattern
- Template Method Pattern
- Visitor Pattern
参考
- Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN 0-201-63361-2.
- 设计模式权威参考。
- 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.
- 一本绝对不负期待去读的好书。
- Dierk Koenig with Andrew Glover, Paul King, Guillaume Laforge and Jon Skeet (2007). Groovy in Action. Manning. ISBN 1-932394-84-2.
- 探讨了Visitor,Builder和其他模式。
- Brad Appleton (1999). Pizza Inversion - a Pattern for Efficient Resource Consumption.
- 一种许多软件工程师都会经常用到的模式!
- Design Patterns in Dynamic Languages by Neil Ford. Houston Java User's Group. Examples in Groovy and Ruby. http://www.hjug.org/present/Neal_Ford-Design_Patterns_in_Dynamic_Languages-slides.pdf
另见: Groovy重构
Labels