易鑫 创始人:FSM的概念和实现(Robert C.Martin和Mina2)

来源:百度文库 编辑:中财网 时间:2024/04/27 18:52:12
FSM的概念和实现(Robert C.Martin和Mina2)2009年06月24日 星期三 16:21

FSM的概念:
FSM(Finite State Machine)有限状态机
模型:状态集+起始状态+输入符号集+转换函数
Moore机:输出只依赖于状态, 行为简单
Mealy机:输出依赖于输入和状态, 状态简约
确定型(DFA)和非确定型(NDFA、GNFA)自动机
典型应用:游戏中AI设计,事件驱动设计
FSM的实现方式:
1) 基于switch/case或者if/else
2) 基于状态表
3) 使用State Pattern:易于维护,新能不差。
4) 使用宏定义描述状态机
参考实现:
http://www.objectmentor.com/resources/downloads.html Robert C.Martin的Java/C++实现
http://mina.apache.org/introduction-to-mina-statemachine.html 基于Mina2的实现【包sandbox.statemachine】
参考资料:
http://en.wikipedia.org/wiki/Finite_state_machine WIKI
http://www.cnblogs.com/swingboat/archive/2005/07/27/201488.html 有限状态机的实现

Downloads

API Design As If Unit Testing Mattered This was presented by Michael C. Feathers at SD West 2007.
SMC - Finite State Machine Compiler (Java) This is the Java version of the SMC. It's in the form of an executable jar file and is able to generate both Java and C++ code. The source, however, is not yet presentable. CommandLineFixture.zip This fixture for the FIT framework (fit.c2.com) provides shell like behavior. A FIT table can specify commands to run, test the output of those commands, create files, test files for existence, and many other features. See http://fit.c2.com/wiki.cgi?SmcRemote for more information
Programming Practices in XP Powerpoint slides This is the Powerpoint presentation that Robert Martin used for his two web seminars on December 12, 2000.
depend.sh - Dependency Analysis Script This is a bash script that calculates the dependencies described in the paper "Object Oriented Design Quality Metrics: an analysis of dependencies". It walks through a directory structure of C++ programs and generates reports that show the values of the metrics for each class category. (text format)
Task Master Examples These are the examples from the TaskMaster article. They used to be at www.oma.com/Taskmaster/Examples. Now they are here.
Zess A simple mailing list server, developed test-first
CppUnit Lite A simple C++ unit-testing tool based on the popular JUnit. See CppTestTools for a complete testing solution that includes FitNesse.

CppTestTools These are the, now famous, C++ Test tools for writing unit tests and FitNesse fixtures in C++. This package includes Capabilities as well as CppFit, makefiles, macros, and many other useful tools and documents to get you going in the world of TDD in C++ or C.
Agile Coaching Presentation A presentation on coaching given at Agile2006.
Vise.zip A simple recording and checking tool to aid refactoring in Java.
Template for UML Diagrams This is the Visio template that Robert Martin and James Newkirk use for creating UML diagrams in their articles and books. It is based upon Pavel Hruby's work, but has several extensions.