I have implemented GUIs using Swing and always tried to follow the MVC pattern as much as I could.
I was wondering though, if MVC is not the only part of the puzzle.
Are FSMs used in GUI's design as well?
I have never used an FSM in a GUI and my approach was: on action, the corresponding method of the controller was called, to endup updating the model, finishing with updating the view.
Usually upon a request triggered by a user's action I used some simple checks to make sure that the user should be able to do the action of the kind:is a specific component enabled? or is the label visible of this kind? etc.
This seems to work so far, but I have to admit that I was "lucky" and did not have to build too complicated-sophisticated or elaborate GUIs.
I have build FSMs before (in different kind off applications -mainly in C++) and I started to wonder if FSMs in GUIs is actually used as a pattern and my approach i.e. to make checks on ActionListeners code, on what the user sees plus what components are enabled or disabled etc. to determine if the user should see some error message instead of being able to do the specific action that e.g. the button promises is actually a bad idea for full-fledged GUI apps.
So when starting to design a GUI besides how to implement the MVC do you fit/associate an FSM in your design?
UPDATE:
After reviewing Dhruv Gairola article in his comment, I am still puzzled on this.
The article mentions building an FSM which is though actually bind to the calculator implementation, meaning that even if the calculator was implemented getting user input without a GUI but via the command line, the FSM would still be needed.
I am still not sure if FSMs to validate user's action on each point in time, is a popular or valid design.
It seems that it could be too much effort and requires that the GUI has been designed completely in advance and all the possible user's action have been mapped to specific results depending on specific states.
Given the fact that there has no been any comments just a one reply, I am tending to think that may be FSM's (to validate a user's actions on controls) are actually not used.
Any input on this is highly welcome.
Thank you.
lets put it this way- design patterns are mainly elaborations of the different design principles e.g. encapsulate what varies, program to an interface, not an implementation, etc. so its not that you HAVE to use a pattern or anything, basically make sure that the way you program conforms to good design principles. if using FSM for a particular design makes design sense, id advice you to go for it. usually patterns are encouraged so that other programmers are able to understand your logic and expand on it easily based on what they know about the pattern. theres no rigid rule saying that you HAVE to use MVC, you HAVE to use blah blah blah.. conclusion: as long as the pattern you're applying conforms to good design principles, (or even if you're not using a specific pattern), make sure its designed well and well enough for others to expand and understand it easily. thats my two cents worth..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With