State transition mechanisms are widely used in software engineering to implement state/event-dependtent behavior.In C/C++,the implementation of state machines using 'switch/case' or "if" statements causes problems in redability ,understandability,maintainability,and modifications.We have devleoped both a source code pattern searching tool cjapale of srarching for state machine occurrences an da design pattern to replace state machines with C++ generic components.With 'ESPaRT' (Enhanced String Pattern Recognition Tool) we search for state machines in the source cod.Examplexs of patterns for stae machine detection are given in the paper.The stae machine information is extracted and hte state machine code is replaced by generic components following the 'generic Harel Sftate Machine Engine' (HSME) design pattern.
展开▼