大杂烩---Step by Step

来源:互联网 发布:windows 连接数据库 编辑:程序博客网 时间:2024/05/01 08:51
 "const关键字只被编译器识别。如果编译器识别不到const,它就不会认为是const的。
比如说,char   *s   =   "12345";
其实,12345"为字符串常量,但是如果你这么做:s[0]   =   '0';那么通过编译是肯定的。但是运行时可能就会出现异常。 "

Design pattern (computer science)

From Wikipedia, the free encyclopedia


Classification

Design patterns can be classified in terms of the underlying problem they solve. Examples of problem-based pattern classifications include:

  • Fundamental patterns
    • Delegation pattern: an object outwardly expresses certain behaviour but in reality delegates responsibility
    • Functional design: assures that each modular part of a computer program has only one responsibility and performs that with minimum side effects
    • Interface pattern: method for structuring programs so that they're simpler to understand
    • Proxy pattern: an object functions as an interface to another, typically more complex, object
    • Facade pattern: provides a simplified interface to a larger body of code, such as a class library.
    • Composite pattern: defines Composite object (e.g. a shape) designed as a composition of one-or-more similar objects (other kinds of shapes/geometries), all exhibiting similar functionality. The Composite object then exposes properties and methods for child objects manipulation as if it were a simple object.
  • Creational patterns which deal with the creation of objects. Abstract Factory and Factory Method are creation patterns
    • Abstract factory pattern: centralize decision of what factory to instantiate
    • Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
    • Builder pattern: separate the construction of a complex object from its representation so that the same construction process can create different representations
    • Lazy initialization pattern: tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed
    • Object pool: avoid expensive acquisition and release of resources by recycling objects that are no longer in use
    • Prototype pattern: used when the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) is prohibitively expensive for a given application
    • Singleton pattern: restrict instantiation of a class to one object
  • Structural patterns that ease the design by identifying a simple way to realize relationships between entities. Adapter is a structural pattern
    • Adapter pattern: 'adapts' one interface for a class into one that a client expects
    • Aggregate pattern: a version of the Composite pattern with methods for aggregation of children
    • Bridge pattern: decouple an abstraction from its implementation so that the two can vary independently
    • Composite pattern: a tree structure of objects where every object has the same interface
    • Decorator pattern: add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes
    • Extensibility pattern: aka. Framework - hide complex code behind a simple interface
    • Facade pattern: create a simplified interface of an existing interface to ease usage for common tasks
    • Flyweight pattern: a high quantity of objects share a common properties object to save space
    • Proxy pattern: a class functioning as an interface to another thing
    • Pipes and filters: a chain of processes where the output of each process is the input of the next
    • Private class data pattern: restrict accessor/mutator access
  • Behavioral patterns that identify common communication patterns between objects and realize these patterns. Interpreter is a behavioral pattern
    • Chain of responsibility pattern: Command objects are handled or passed on to other objects by logic-containing processing objects
    • Command pattern: Command objects encapsulate an action and its parameters
    • Interpreter pattern: Implement a specialized computer language to rapidly solve a specific set of problems
    • Iterator pattern: Iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation
    • Mediator pattern: Provides a unified interface to a set of interfaces in a subsystem
    • Memento pattern: Provides the ability to restore an object to its previous state (rollback)
    • Null Object pattern: Designed to act as a default value of an object
    • Observer pattern: aka Publish/Subscribe or Event Listener. Objects register to observe an event which may be raised by another object
    • State pattern: A clean way for an object to partially change its type at runtime
    • Strategy pattern: Algorithms can be selected on the fly
    • Specification pattern: Recombinable Business logic in a boolean fashion
    • Template method pattern: Describes the program skeleton of a program
    • Visitor pattern: A way to separate an algorithm from an object
    • Single-serving visitor pattern: Optimise the implementation of a visitor that is allocated, used only once, and then deleted
    • Hierarchical visitor pattern: Provide a way to visit every node in a hierarchical data structure such as a tree.
  • Concurrency patterns
    • Active Object
    • Balking pattern
    • Double checked locking pattern
    • Guarded suspension
    • Leaders/followers pattern
    • Monitor Object
    • Read write lock pattern
    • Scheduler pattern
    • Thread pool pattern
    • Thread-Specific Storage
    • Reactor pattern
原创粉丝点击