Web Development – What is NOT MVC in a Web Application?

designdesign-patternsmvcweb-applicationsweb-development

It is easy to find many descriptions of what MVC is – for instance here, here or in this video.

I'm curious, what is NOT MVC?

or more precisely – In a MVC-using app, what is everything else apart form MVC?

.

I see the tendency to start explaining MVC in a form of

Separate the application into three parts[…]

Which seems to suggest that you should try to fit in as much as you can (or all) of your design under either Model, View or Controller.

.

Yet, it's easy to see that in most explenations MVC is primarily described as a user interface design. How in this situation do I treat non-UI elements?

  • Do I bend definitions of non-UI elements and try to figure out whether they could fit to either Model or Controller?
  • Is there a separete description in MVC design that deals with non-UI elements?
  • Is there a description of how MVC interacts with such elements? Is it all through Model? All through Controller?

.

For example:

I'm wondering how do I treat the part of my application which is used only for monitoring my local network and storing the information in a database. It has no UI related functionality and its sole puprose is to fill in the database with file related information, which then in turn is presented to the user through the web interface.

Best Answer

I'm wondering how do I treat the part of my application which is used only for monitoring my local network and storing the information in a database.

Several architectures implement such code differently, but in a layered architecture, you would need to create layers, e.g. DataAccess layer, Business logic layer. etc..

Your Model (there are different types of models) will interact with these layers as required, it all depends on your application or software architecture really.

Do I bend definitions of non-UI elements and try to figure out whether they could fit to either Model or Controller ?

I would say your "non-UI elements" is actually your business logic that needs to go in Model which then can interact with different layers e.g. DB layer etc..

Should I add logic to my Controller

enter image description here

Further Recommendations

Here are couple of sample projects developed based on DDD using MVC and other technologies that may help you understand this subject further,

EFMVC - ASP.NET MVC 4, Entity Framework 5 Code First and Windows Azure

Sample web app for ASP.NET MVC 5, EF 6 Code First, AutoMapper, Autofac and TDD