Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teacher confused about MVC?

I have an assignment to create a game in java using MVC as a pattern. The thing is that stuff I read about MVC aren't really what the teacher is telling me.

What I read is that the Model are the information objects, they are manipulated by the controllers. So in a game the controller mutates the placement of the objects and check if there is any collision etc.

What my teacher told me is that I should put everything that is universal to the platform in the models and the controllers should only tell the model which input is given. That means the game loop will be in a model class, but also collision checks etc. So what I get from his story is that the View is the screen, the Controller is the unput handeler, and the Model is the rest.

Can someone point me in the right direction?

like image 587
Gideon Avatar asked Nov 09 '13 09:11

Gideon


People also ask

What is MVC architecture with example?

Building Web Applications with ASP.NET Core 3 MVC The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

What do models do in MVC?

The Model is the part of MVC which implements the domain logic. In simple terms, this logic is used to handle the data passed between the database and the user interface (UI). The Model is known as domain object or domain entity. The domain objects are stored under the Models folder in ASP.NET.

What is the role of controller in MVC?

A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.

What is MVC design pattern in Java?

MVC Pattern stands for Model-View-Controller Pattern. This pattern is used to separate application's concerns. Model - Model represents an object or JAVA POJO carrying data. It can also have logic to update controller if its data changes. View - View represents the visualization of the data that model contains.


1 Answers

There actually are multiple valid implementations of the MVC pattern to a given application. What fundamentally characterizes an application as an MVC application is that the developer(s) seperate functionalities into the three broad categories model, view and controller.

For the most part, the model contains an abstraction of the current state of the application and/or the underlying data. The view comprises everything that handles presentation. The controller typically is a middling instance between view and model and vice versa: e.g. if user input modifies the data model, the controller is ought to apply these changes (or void them if they are invalid); and the other way round, if a state in the model is present that is defined to result in a certain output to the view the controller will enforce this.

These are blurred lines however. The applicability of an MVC design typically is limited by the programming language you are using.

In other words, you have to improvise to some degree. Seperate functionalities as much as it is sensible but do not overdo it where it does not make sense.


A few resources:

  1. IBM
  2. Wikipedia
like image 111
FK82 Avatar answered Oct 26 '22 17:10

FK82