Design Pattern | 设计模式

Do you use design patterns?
[url]http://stackoverflow.com/questions/11586/do-you-use-design-patterns[/url][quote]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.[/quote]

[img]http://dl2.iteye.com/upload/attachment/0082/2554/460ffada-f8f5-3773-8551-924d16165201.gif[/img]


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


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

Structural比较 之:装饰 组合

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

[b][url]http://www.vincehuston.org/dp/[/url]
http://www.jdon.com/designpatterns/index.htm
[/b]

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

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

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

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

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


[b]Lazy loading 懒加载 模式的设计与实现:[/b]
[url]http://jtechies.blogspot.com/2012/07/item-71-use-lazy-initialization.html[/url]
[url]http://stackoverflow.com/questions/3578604/how-to-solve-the-double-checked-locking-is-broken-declaration-in-java[/url]
[url]http://timezra.blogspot.com/2008/04/threadsafe-lazy-instantiation-without.html[/url]
[url]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[/url]
[url]http://twit88.com/blog/2008/01/22/design-pattern-in-java-101-lazy-load-part-i/[/url]
[url]http://www.javabeat.net/2012/07/lazy-initialisation-singleton-and-double-check-locking/[/url]


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


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


Builder Pattern(建造者模式/生成器模式):
[b][color=red]极好的Builder范例[/color]:[url]http://blog.crisp.se/2013/10/09/perlundholm/another-builder-pattern-for-java[/url][/b]
[b]Builder 和 继承:[/b][quote][url]https://weblogs.java.net/node/642849[/url]
[url]http://egalluzzo.blogspot.com/2010/06/using-inheritance-with-fluent.html[/url][url][/quote][url]http://www.javacodegeeks.com/2012/07/builder-design-pattern-in-java.html[/url]
[url]http://www.drdobbs.com/jvm/creating-and-destroying-java-objects-par/208403883?pgno=2[/url]
eclipse中生成 Builder,代码,见:
[url]http://wuaner.iteye.com/blog/444391[/url]


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

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


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


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


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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值