1

I want to use MVC and State patterns in a game what I am developing but I don´t know how link both patterns. I think a state (state pattern) is a view from MVC pattern but when app changes the state, how it knows what controller and model must use? I thinked in Facade Pattern but.. I think it is not the best idea.

What is the best practise about it?

1 Answer 1

-1

You're entirely confused on MVC and the state pattern.

  • Model: Data model. This represents the state of your data (not your application)
  • View: Just as it says. The VIEW you see
  • Controller: Business logic controller. This is representation of application state as business logic is applied

All computer programs are finite state machines. So, the "State" pattern applies to everything.

In the context of the state pattern this is about very specific and closed state transition. For example, you can consider TCP states:

In general, your question is not specific to design patterns, the state machine or MVC. It's overly broad

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I am not confusing MVC and State patterns. I understand both but I don´t know how they can work together. If I develop a game under MVC pattern and I want to change States (menu and map, for example) I think I need to change View at runtime. Well, if user select a menu item, menu controller will set a new State in the app context to change the view but, how can I know what controller belongs to that view at runtime?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.