Miranda use hierarchical states.
Hierarchical means that behavior can be shared across several classes. This is very useful if you are sharing files, as Miranda does, and you don't want to write the same code over and over again.
I first heard about hierarchical states with Harel Statecharts, but I later used ROOMcharts (part of the late, Real-Time Object-Oriented Modeling methodology that later got absorbed into UML) because I liked them better.
The nice thing about hierarchical states are that you can define a behavior in a base state and all states that extend it get that behavior as well. In the case of Miranda, the State class, that all state classes extend, responds to the stop message. That way, all classes "know" how to stop.
Some classes do a bit more. The ToipicFile class checks to see if it needs to be written, while the Node class, which represents different nodes in the cluster, needs to disconnect before shutting down. The state classes for these objects know to watch for a shut down message, and behave differently in those cases.
Saturday, March 18, 2017
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment