Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why not have the context class inherit from the application class?

0
Posted

Why not have the context class inherit from the application class?

0

Because: • SMC is designed to be as loosely-coupled with your application code as possible. The SMC Programmer’s Manual section 3 shows just how little code it takes to hook an SMC-generated state machine into your class. • Robert Martin’s FSM pattern is not as loosely-coupled as I would like. With Robert Martin’s pattern, you write the Turnstile class and and then have AppClassFSM inherit from Turnstile. You then instantiate the TurnstileFSM class and work with that object. I think this is unnatural. My inclination is to instantiate Turnstile because that is what corresponds to the “real” world. SMC does a variation on this theme. It generates a TurnstileContext class which inherits from FSMContext class and keeps a reference to the Turnstile object which instantiated it. TurnstileContext stores the current state and defines the “transition” methods which Turnstile calls when it issues a transition. For a more detailed explanation of what patterns SMC uses, see the SMC Programmer’s Ma

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123