Questions tagged [model-view-controller]

Model–View–Controller (MVC) is an architectural pattern, introduced in mid 1970-s in PARC into how to compose software interfacing also with user-interactions. For Microsoft ASP.NET MVC, please use [] or [] tag instead. For Spring MVC, please use [spring-mvc] tag instead.

Model–View–Controller (MVC) is an architectural pattern used in software engineering, since Palo Alto Research Centre released one such in mid 1970-ies, designed in Smalltalk-79 language.

The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing, portability and maintenance of each (separation of concerns).

Image which demonstrates typical collaboration of the MVC components:



The analogy

MVC can be metaphorically related to a TV. You have various channels, with different information on them supplied by your cable provider (the model). The TV screen displays these channels to you (the view). You pressing the buttons on the remote controls affects what you see and how you see it (the controller).

33635 questions
24 answers

What are MVP and MVC and what is the difference?

When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-View-Presenter and Model-View-ViewModel. My…
44 answers

Passing data between view controllers

I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following: I have a view that acts as a data entry form and I want to give the user the option to select multiple products. The products are listed on another view with…
Matt Price
  • 34,499
  • 6
  • 24
  • 33
24 answers

What is the difference between MVC and MVVM?

Is there a difference between the standard "Model View Controller" pattern and Microsoft's Model/View/ViewModel pattern?
Bjorn Reppen
  • 22,007
  • 9
  • 64
  • 88
9 answers

Separation of business logic and data access in django

I am writing a project in Django and I see that 80% of the code is in the file This code is confusing and, after a certain time, I cease to understand what is really happening. Here is what bothers me: I find it ugly that my model level…
5 answers

How should a model be structured in MVC?

I am just getting a grasp on the MVC framework and I often wonder how much code should go in the model. I tend to have a data access class that has methods like this: public function CheckUsername($connection, $username) { try { …
  • 9,983
  • 11
  • 28
  • 33
21 answers

MVC pattern on Android

Is it possible to implement the model–view–controller pattern in Java for Android? Or is it already implemented through Activities? Or is there a better way to implement the MVC pattern for Android?
Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251
12 answers

What is a Data Transfer Object (DTO)?

In MVC are the model classes DTO? If not, what are the differences and do we need both?
7 answers

Where to put model data and behaviour? [tl; dr; Use Services]

I am working with AngularJS for my latest project. In the documentation and tutorials all model data is put into the controller scope. I understand that is has to be there to be available for the controller and thus within the corresponding…
Nils Blum-Oeste
  • 5,608
  • 4
  • 25
  • 26
6 answers

What is difference between MVC, MVP & MVVM design pattern in terms of coding c#

If we search Google using the phrase "differences between MVC, MVP & MVVM design pattern" then we may get a few URL's which discuss the difference between MVC MVP & MVVM design pattern theoretically like: MVP Use in situations where binding via a…
  • 33,544
  • 126
  • 357
  • 626
5 answers

Can I get the name of the current controller in the view?

Is there a way to figure out what the current controller is from within the view? For an example of why I would want to know this: if several controllers share the same layout, I may have a part in the layout ERB file where I want to highlight the…
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
9 answers

Java / Jakarta EE web development, where do I start and what skills do I need?

I want to learn, at least at a basic level, how to build Java web applications (coming from a .NET background). I would like to be able to build, deploy a simple CMS type application from the ground up. What exactly do I need to learn? Tomcat seems…
  • 99,669
  • 140
  • 310
  • 420
10 answers

Business logic in MVC

I have 2 questions: Q1. Where exactly does "business logic" lie in the MVC pattern? I am confused between Model and Controller. Q2. Is "business logic" the same as "business rules"? If not, what is the difference? It would be great if you could…
7 answers

Add directives from directive in AngularJS

I'm trying to build a directive that takes care of adding more directives to the element it is declared on. For example, I want to build a directive that takes care of adding datepicker, datepicker-language and ng-required="true". If I try to add…
13 answers

What goes into the "Controller" in "MVC"?

I think I understand the basic concepts of MVC - the Model contains the data and behaviour of the application, the View is responsible for displaying it to the user and the Controller deals with user input. What I'm uncertain about is exactly what…
Paul Walker
  • 2,698
  • 4
  • 20
  • 20
5 answers

Difference between Observer, Pub/Sub, and Data Binding

What is the difference between the Observer Pattern, Publish/Subscribe, and Data Binding? I searched around a bit on Stack Overflow and did not find any good answers. What I have come to believe is that data binding is a generic term and there are…
2 3
99 100