Design Patterns always helped designers to solve recurring problems. But design patterns are conceptual and too generic. The framework on the other hand is more specific to a particular domain and can be realized through the code. The state pattern is a very useful and powerful pattern which enables an object to change its behavior at run time, depends on which state it is in. A kind of changing the class of an object at run time!!. You may find more information about this design pattern here.
If you are aware this pattern you might have realized that it needs to have many classes, each represents a state the object may have in its life time. The real object, often called as Context, doesn't hold any internal flag or variables to keep track of the current state, instead it delegates the work to the state object which is currently active. The state object contacts the Context back, to do the appropriate work if needed and may change the state itself. It is better to keep all the implementation code in the Context and state objects will only take care of which method to invoke in the Context and when to change the state.
An object, which is an encapsulation of a real world entity, might have many states in its life span, and its is absolutely difficult to write classes for each state and the transition logic. State diagrams are used to depict the behavior of the object at various state and its transition logic. Its up to the programmer to realize the design. And of-course each programmer has their own way of implementing it. Which leads to consistent code, difficult to review, difficult to test and difficult to maintain.
This fact, motivated the designers of SmartState to develop a framework which is generic and can be used in almost all application domains. This framework solves few of the problems described above and still the major part of writing the classes is left. So we realized a need for automatic code generation from the design. To accomplish that, state diagrams should not be drawn, it should be modeled. SmartState Designer GUI provides the user with a simple and effective user interface to model the state transitions. Special care is taken to avoid putting all the restrictions in the design time because it may be iterative. The design is free to model and the constraints and restrictions are applied only in the code generation stage which makes the GUI more user friendly.
The code generator will analyze the model, checks for necessary constraints and does the most time consuming part of writing the classes. The generated classes are ready to compile and need not be modified. This is a very important feature of SmartState because the design and the implementation is one-to-one always which is usually a day dream in software industry.
To change the behavior of the object, just edit and recompile the model. Rebuild your project and you are done. You may not need a programmer to do this. Which makes it more maintainable. Also the code generated is of the same structure, the review and testing need not be done once you are satisfied with it. All these features lead to improved productivity in your organization which is the motivation of SmartState.
Here are some key features of "SmartState":
· Simple graphic modeler for state diagrams.
· Designers and developers can work on same tool.
· Ready to compile C++ / C / Java / C# code. No scripting required.
· Robust state machine framework.
· Message based architecture. Easy to integrate.
· Supports nested, super & concurrent states.
· State machine can be persisted and reinitialized to same state.
· Supports Internal messages.
· Customizable code generation.
· XML API for the model for further customization.
· 30 launches
What's New in This Release:
· Multi language support ; SmartState Studio is available now in: French, German, Spanish and English