2011年7月1日

Design Pattern----27.Behavioral.Vistor.Pattern (Delphi Sample)

摘要: IntentRepresent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. The classic technique for recovering lost type information. Do the right thing based on the type of two obje 阅读全文

posted @ 2011-07-01 14:00 Tony Liu 阅读(652) 评论(0) 推荐(0) 编辑

Design Pattern----26.Behavioral.TemplateMethod.Pattern (Delphi Sample)

摘要: IntentDefine the skeleton of an algorithm in an operation, deferring some steps to client subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure. Base class declares algorithm ‘placeholders’, and derived classes implement the pla 阅读全文

posted @ 2011-07-01 13:52 Tony Liu 阅读(480) 评论(0) 推荐(0) 编辑

Design Pattern----25.Behavioral.Strategy.Pattern (Delphi Sample)

摘要: IntentDefine a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it. Capture the abstraction in an interface, bury implementation details in derived classes. ProblemOne of the dominant strategies of obj 阅读全文

posted @ 2011-07-01 13:38 Tony Liu 阅读(628) 评论(0) 推荐(0) 编辑

Design Pattern----24.Behavioral.State.Pattern (Delphi Sample)

摘要: IntentAllow an object to alter its behavior when its internal state changes. The object will appear to change its class. An object-oriented state machine wrapper + polymorphic wrappee + collaboration ProblemA monolithic object’s behavior is a function of its state, and it must change its behavior at 阅读全文

posted @ 2011-07-01 13:32 Tony Liu 阅读(1336) 评论(0) 推荐(0) 编辑

Design Pattern----23.Behavioral.Observer.Pattern (Delphi Sample)

摘要: IntentDefine a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Encapsulate the core (or common or engine) components in a Subject abstraction, and the variable (or optional or user interface) components in an Ob 阅读全文

posted @ 2011-07-01 13:26 Tony Liu 阅读(1069) 评论(0) 推荐(0) 编辑

Design Pattern----22.Behavioral.Null Object.Pattern (Java Sample)

摘要: IntentThe intent of a Null Object is to encapsulate the absence of an object by providing a substitutable alternative that offers suitable default do nothing behavior. In short, a design where “nothing will come of nothing” Use the Null Object pattern when an object requires a collaborator. The Null 阅读全文

posted @ 2011-07-01 13:21 Tony Liu 阅读(538) 评论(0) 推荐(0) 编辑

Design Pattern----21.Behavioral.Memento.Pattern (Delphi Sample)

摘要: IntentWithout violating encapsulation, capture and externalize an object’s internal state so that the object can be returned to this state later. A magic cookie that encapsulates a “check point” capability. Promote undo or rollback to full object status. ProblemNeed to restore an object back to its 阅读全文

posted @ 2011-07-01 13:15 Tony Liu 阅读(577) 评论(0) 推荐(0) 编辑

Design Pattern----20.Behavioral.Mediator.Pattern (Delphi Sample)

摘要: IntentDefine an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. Design an intermediary to decouple many peers. Promote the many-to-many relations 阅读全文

posted @ 2011-07-01 12:59 Tony Liu 阅读(732) 评论(0) 推荐(0) 编辑

Design Pattern----19.Behavioral.Iterator.Pattern (Delphi Sample)

摘要: IntentProvide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. The C++ and Java standard library abstraction that makes it possible to decouple collection classes and algorithms. Promote to “full object status” the traversal of a collec 阅读全文

posted @ 2011-07-01 12:52 Tony Liu 阅读(672) 评论(0) 推荐(0) 编辑

Design Pattern----18.Behavioral.Interpreter.Pattern (Delphi Sample)

摘要: IntentGiven a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design. ProblemA class of problems o 阅读全文

posted @ 2011-07-01 12:41 Tony Liu 阅读(421) 评论(0) 推荐(0) 编辑

Design Pattern----17.Behavioral.Command.Pattern (CSharp Sample)

摘要: IntentEncapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. Promote “invocation of a method on an object” to full object status An object-oriented callback ProblemNeed to issue requests to objects 阅读全文

posted @ 2011-07-01 12:31 Tony Liu 阅读(484) 评论(0) 推荐(0) 编辑

Design Pattern----16.Behavioral.Chain of Responsibility.Pattern

摘要: IntentAvoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. Launch-and-leave requests with a single processing pipeline that contains many poss 阅读全文

posted @ 2011-07-01 11:43 Tony Liu 阅读(425) 评论(0) 推荐(0) 编辑

Design Pattern----Behavioral.Pattern

摘要: In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.Chain of responsibility A way of passing a request betwe 阅读全文

posted @ 2011-07-01 11:37 Tony Liu 阅读(279) 评论(0) 推荐(0) 编辑

Design Pattern----14.Structural.Proxy.Pattern (CSharp Sample)

摘要: IntentProvide a surrogate or placeholder for another object to control access to it. Use an extra level of indirection to support distributed, controlled, or intelligent access. Add a wrapper and delegation to protect the real component from undue complexity. ProblemYou need to support resource-hung 阅读全文

posted @ 2011-07-01 11:19 Tony Liu 阅读(285) 评论(0) 推荐(0) 编辑

Design Pattern----13.Structural.Private.Pattern (CSharp Sample)

摘要: IntentControl write access to class attributes Separate data from methods that use it Encapsulate class data initialization Providing new type of final - final after constructorProblemA class may expose its attributes (class variables) to manipulation when manipulation is no longer desirable, e.g. a 阅读全文

posted @ 2011-07-01 11:14 Tony Liu 阅读(332) 评论(0) 推荐(0) 编辑

Design Pattern----12.Structural.Flyweight.Pattern (Delphi Sample)

摘要: Intent Use sharing to support large numbers of fine-grained objects efficiently. The Motif GUI strategy of replacing heavy-weight widgets with light-weight gadgets. Problem Designing objects down to t... 阅读全文

posted @ 2011-07-01 11:10 Tony Liu 阅读(587) 评论(0) 推荐(0) 编辑

导航