State machines can be implemented by using several methods. Although state pattern (SP) implementation is one of the most popular methods, nowadays usage of hierarchical state machine (HSM) pattern is increasing. In this paper our motivation is making a metric based comparison between HSM and SP pattern. In addition, effect of increase in usage of inheritance in HSM pattern is analyzed. SP and HSM pattern belongs to different software methodologies, thus usage of object-oriented (OO) metrics is not applicable. However, both patterns implement state machines. For this reason, a new metric suit for state machines is proposed. As a result of this study, it is shown that using inheritance effectively in HSM pattern increases software quality. In addition, it is shown that HSM pattern handles enter/exit actions more effectively than SP. event e with the same transition a. Both states go to the same state; S3, with event e. S1 and S2 can be grouped under S12. By doing so, the number of events and transitions is reduced with the help of inheritance.
Read full abstract