设计模式与框架——课程总结

DPF课程的考前总结,备份一下,图片后面补充。

Behavioral Variability Patterns

  • Template Method: Define the skeleton of algorithm in template method and redefine some primitive operations in subclasses (without changing the structure of the algorithm). In Template Method pattern, template and hook are implemented with the same class but different methods. (Role Model的视角看,Caller和Callee是equivalence关系。)
  • Objectifier: Hook method can be split out of the class and put into a seperate object.
  • Template Class: Combine Template Method and Objectifier. Hook objects can be exchanged at run time to exchange a set of methods.
  • Strategy: Talks about the exchange of algorithm.
  • Generic Template Class: Use static generic expansion to realize template class, which provides more type safety and less runtime dispatch.
  • Dimensional Class Hierarchy: Vary the template class in a class hierarchy. Concrete template classes can change the template algorithm.
  • Bridge: A variant of DCH with different incentive. The intention is to seperate the abstraction and implementation so that they can vary independently.
  • Visitor: Also a variant of DCH. One can define a new operation without changing the classes of the elements on which it operates. Visitor is used when many distinct and unrelated operations need to be performed on objects in an object structure, where the objects rarely change.
  • Facet Classification: Seperate concerns into different facets. These facets are orthogonal dimensions of the model.
  • Layered Objects: If dimensions in a Bridge have dependencies, then a contract is needed between dimensions. Layered objects shows the dimension dependencies. Upper layers depend on information of lower layers.

继续阅读“设计模式与框架——课程总结”