`

Design Pattern | 设计模式

阅读更多

Do you use design patterns?
http://stackoverflow.com/questions/11586/do-you-use-design-patterns
引用
Any large program that is well written will use design patterns, even if they aren't named or recognized as such. That's what design patterns are, designs that repeatedly and naturally occur. If you're interfacing with an ugly API, you'll likely find yourself implementing a Facade to clean it up. If you've got messaging between components that you need to decouple, you may find yourself using Observer. If you've got several interchangeable algorithms, you might end up using Strategy.
It's worth knowing the design patterns because you're more likely to recognize them and then converge on a clean solution more quickly. However, even if you don't know them at all, you'll end up creating them eventually (if you are a decent programmer).
And of course, if you are using a modern language, you'll probably be forced to use them for some things, because they're baked into the standard libraries.





通过Java例子代码学习设计模式:
https://thenewcircle.com/bookshelf/java_fundamentals_tutorial/design_patterns.html
http://www.avajava.com/tutorials/categories/design-patterns



设计模式最佳例子之JAVA API:
Examples of GoF Design Patterns [closed]:
http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns
Design Patterns in the JDK:
http://www.briandupreez.net/2010/11/design-patterns-in-jdk.html


Structural比较 之:装饰 组合

Behavioral比较 之:策略 状态 命令
http://www.cnblogs.com/Mainz/archive/2007/12/15/996081.html

http://www.vincehuston.org/dp/
http://www.jdon.com/designpatterns/index.htm


Iterator:
http://www.journaldev.com/1716/iterator-design-pattern-in-java-example-tutorial

http://www.scribd.com/doc/16738161/Java-Design-Patterns-With-Examples#outer_page_46

设计模式笔记
http://www.riabook.cn/doc/designpattern/

设计模式之禅,写的不错哈:
http://cbf4life.iteye.com/
http://www.cnblogs.com/cbf4life/tag/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/

23设计模式
http://www.cnblogs.com/singlepine/category/59538.html


Lazy loading 懒加载 模式的设计与实现:
http://jtechies.blogspot.com/2012/07/item-71-use-lazy-initialization.html
http://stackoverflow.com/questions/3578604/how-to-solve-the-double-checked-locking-is-broken-declaration-in-java
http://timezra.blogspot.com/2008/04/threadsafe-lazy-instantiation-without.html
http://books.google.com/books?id=Jl5rkQnbfAIC&pg=PA202&lpg=PA202&dq=java+lazy+load+list+object&source=bl&ots=guy4dQmaJU&sig=TjbgDB3Y4hds8--zh563hcavqGI&hl=en&sa=X&ei=6FZ1Uq70GcqErAfzpIDACA&ved=0CJcEEOgBMDc#v=onepage&q=java%20lazy%20load%20list%20object&f=false
http://twit88.com/blog/2008/01/22/design-pattern-in-java-101-lazy-load-part-i/
http://www.javabeat.net/2012/07/lazy-initialisation-singleton-and-double-check-locking/


filter 模式的设计与实现:
http://stackoverflow.com/questions/18062023/interface-method-that-has-different-parameters-in-java
http://erikras.com/2008/01/18/the-filter-pattern-java-conditional-abstraction-with-iterables/


非常好的一篇关于责任链模式的文章:
http://www.cnblogs.com/java-my-life/archive/2012/05/28/2516865.html


Builder Pattern(建造者模式/生成器模式):
极好的Builder范例http://blog.crisp.se/2013/10/09/perlundholm/another-builder-pattern-for-java
Builder 和 继承:
引用
[url]http://www.javacodegeeks.com/2012/07/builder-design-pattern-in-java.html
http://www.drdobbs.com/jvm/creating-and-destroying-java-objects-par/208403883?pgno=2
eclipse中生成 Builder,代码,见:
http://wuaner.iteye.com/blog/444391


关于State Pattern一篇好E文:
http://www.informit.com/guides/content.aspx?g=java&seqNum=576

Bridge pattern:
hhttp://javapapers.com/design-patterns/bridge-design-pattern/
http://www.oodesign.com/bridge-pattern.html


用 Decorator 设计邮件发送程序的一个例子:
http://www.developer.com/tech/article.php/3689436/Working-with-Design-Pattern-Decorator.htm


Simple Factory vs. Factory Method vs. Abstract Factory:
http://corey.quickshiftconsulting.com/1/post/2009/5/first-post.html


There are three kinds of design patterns:

Creational patterns:
They are related with how objects and classes are created. While class-creation patterns use inheritance effectively in the instantiation process,while object-creation patterns use delegation to get the job done.
* Abstract Factory groups object factories that have a common theme.
* Builder constructs complex objects by separating construction and representation.
* Factory Method creates objects without specifying the exact object to create.
* Prototype creates objects by cloning an existing object.
* Singleton restricts object creation for a class to only one instance.

Structural patterns:
They are related to class and object composition.This pattern uses inheritance to define new interfaces in order to compose new objects and hence new functionalities.
* Adapter allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class.
* Bridge decouples an abstraction from its implementation so that the two can vary independently.
* Composite composes one-or-more similar objects so that they can be manipulated as one object.
* Decorator dynamically adds/overrides behavior in an existing method of an object.
* Facade provides a simplified interface to a large body of code.
* Flyweight reduces the cost of creating and manipulating a large number of similar objects.
* Proxy provides a placeholder for another object to control access, reduce cost, and reduce complexity.

Behavioral patterns:
These design patterns deal with objects communication. They are specifically concerned with communication between objects.
* Chain of responsibility delegates commands to a chain of processing objects.
* Command creates objects which encapsulate actions and parameters.
* Interpreter implements a specialized language.
* Iterator accesses the elements of an object sequentially without exposing its underlying representation.
* Mediator allows loose coupling between classes by being the only class that has detailed knowledge of their methods.
* Memento provides the ability to restore an object to its previous state (undo).
* Observer is a publish/subscribe pattern which allows a number of observer objects to see an event.
* State allows an object to alter its behavior when its internal state changes.
* Strategy allows one of a family of algorithms to be selected on-the-fly at runtime.
* Template method defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.
  • 大小: 64.6 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics