Introduction to State Design Pattern
来源:互联网 发布:微信复制淘宝打不开 编辑:程序博客网 时间:2024/05/21 09:50
In software development, a pattern (or design pattern) is a written document that describes a general solution to a design problem that recurs repeatedly in many projects. Software designers adapt the pattern solution to their specific project. Patterns use a formal approach to describing a design problem, its proposed solution, and any other factors that might affect the problem or the solution.
In object-oriented programming, a pattern can contain the description of certain objects and object classes to be used, along with their attributes and dependencies, and the general approach to how to solve the problem. Similarly, state patterns started to appear. In contrast to the OO patterns, which are concerned with optimal ways of structuring classes and objects, the state design patterns focus on effective ways of structuring states, events and transitions.
Just as an OO pattern, a state pattern has five essential elements:
1. The pattern name: a word or two denoting the problem, solution and the consequences of a pattern. A good name is vital, because it will become part of your vocabulary.
2. The problem: explanation of the problem the pattern addresses. A problem is often motivated by an example.
3. The solution: description of the elements (states, transitions, events, actions, and extended state variables) comprising the solution, their relationships, responsibilities and collaborations.
4. The sample code: presentation of a concrete implementation of an instance of the pattern. Usually the sample code implements the motivating example.
5. The consequences: the results and trade-offs of applying the pattern.
The following sections describe some state design patterns which are adapted from "Practical Statecharts in C/C++: Quantum Programming for Embedded Systems" Miro Samek, Ph.D. Quantum Leaps.
In object-oriented programming, a pattern can contain the description of certain objects and object classes to be used, along with their attributes and dependencies, and the general approach to how to solve the problem. Similarly, state patterns started to appear. In contrast to the OO patterns, which are concerned with optimal ways of structuring classes and objects, the state design patterns focus on effective ways of structuring states, events and transitions.
Just as an OO pattern, a state pattern has five essential elements:
1. The pattern name: a word or two denoting the problem, solution and the consequences of a pattern. A good name is vital, because it will become part of your vocabulary.
2. The problem: explanation of the problem the pattern addresses. A problem is often motivated by an example.
3. The solution: description of the elements (states, transitions, events, actions, and extended state variables) comprising the solution, their relationships, responsibilities and collaborations.
4. The sample code: presentation of a concrete implementation of an instance of the pattern. Usually the sample code implements the motivating example.
5. The consequences: the results and trade-offs of applying the pattern.
The following sections describe some state design patterns which are adapted from "Practical Statecharts in C/C++: Quantum Programming for Embedded Systems" Miro Samek, Ph.D. Quantum Leaps.
- Introduction to State Design Pattern
- Design Pattern 18-state
- State Design Pattern: Reminder
- State Design Pattern
- Java Design Pattern: State
- Design Pattern(3)-State Pattern
- Design Pattern Introduction
- Design Pattern:1 introduction
- State Design Pattern: Ultimate Hook
- Design Pattern - State(C#)
- design pattern——state
- Design Pattern Introduction and Practice
- [Special] Design Pattern - Behavioral Patterns - State Pattern
- State Design Pattern 状态设计模式
- State Design Pattern 状态设计模式2
- 状态模式(State Design Pattern)
- Design Pattern Introduction – catch the core
- introduction to data oriented design
- 昨天考驾照
- UML Tool Features
- IT从业人员必看的10个论坛
- Ebox还没到,可怎么办呢
- 程序员每天该做的事
- Introduction to State Design Pattern
- State Design Pattern: Ultimate Hook
- C++ BUILDER中关于image字段的写法
- State Design Pattern: Reminder
- SKYPE竟然改用BCB来编译了?。。。
- LPC2210(2)
- 西行漫记(13):Show Time
- 初识fedora
- 累~