Skip to main content
66 votes

What are the improvements of MVP over MVC?

MVC is conceptually elegant: user input is handled by the controller the controller updates the model the model updates the view/user interface +---+ +----| V |<----+ user | +...
amon's user avatar
  • 135k
32 votes
Accepted

MVC and RESTful API service

MVC is a paradigm from the Smalltalk world concerned with how object orientated systems could have UIs. Early web frameworks took the general idea (separate out business logic, controlling logic and ...
Cormac Mulhall's user avatar
18 votes

Testing: deterministic or non-deterministic?

Both. Deterministic and nondeterministic tests have different use cases and different values to your suite. Generally nondeterministic can't provide the same precision as deterministic testing, which ...
Hovercouch's user avatar
18 votes
Accepted

Patterns are not building blocks – so I shouldn't build an app on MVC/MVP patterns?

If I understand correctly, this means not to use a design pattern until it makes sense to do so, correct? Yes. Don't start off saying you're going to use the Strategy Pattern, wait until you ...
Ixrec's user avatar
  • 27.6k
12 votes
Accepted

How to architecture a realtime-heavy websockets-based web application?

How to structure the data that is sent from the server to the user? Use the messaging pattern. Well, you're already using a messaging protocol, but I mean structure the changes as messages... ...
Kasey Speakman's user avatar
12 votes
Accepted

Proper design to avoid the use of dynamic_cast?

I would like to expand on Emerson Cardoso's "other suggestion" because I believe it to be the correct approach in the general case - though you may of course find other solutions better suited to any ...
doubleYou's user avatar
  • 2,837
11 votes

MVC and RESTful API service

View is a layer responsible for displaying information which may be interpreted by a user/client of your application (it does not say the user has to be an actual person). JSON is completely valid ...
Andy's user avatar
  • 10.4k
10 votes

Why does everyone put controllers in one folder and views in another?

Whatever the reason, this is poor practise. It is very anti-OO because packages or folders (whatever you want to call them), should have weak inter-dependencies. Classes (or files) inside them should ...
Oliver Watkins's user avatar
10 votes
Accepted

MVC: Display requested content via the View

Model View Controller is one of the oldest if not first design patterns. It was created at a time when few people understood any proper way for objects to interact. Consequently the only common ...
candied_orange's user avatar
10 votes
Accepted

The right place for "app logic" in MVVM context

In MVVM, the business logic is built into the Model. The ViewModel is there to bridge between the View and the Model, so it's logic only pertains to driving the display and updating the model from ...
Berin Loritsch's user avatar
9 votes
Accepted

Storing directly in the model

When you use void updateTitle(String str) { this.title = str this.store.update(this); this.notifier.notifyAboutChange(this); } you are grouping two operations into one -- updating the ...
R Sahu's user avatar
  • 1,986
9 votes
Accepted

Should I always use the MVC pattern (or similar) for big, graphical and professional applications?

The advantage of being able to program to many different GUI's is minimized if you only have one GUI. But understand that you have multiple GUI's if you ever update your GUI. The point of decoupling ...
candied_orange's user avatar
9 votes
Accepted

What alternative name to give to controllers?

The point about avoiding "smurf naming" is not to think of synonyms for "smurf", but to not use the term. So the thinking goes that if you have a user controller in a folder called Controllers, then ...
David Arno's user avatar
  • 39.4k
9 votes

Do we need Models if we are using ViewModels?

Having a Model and a ViewModel promotes separation of concerns by allowing your Model to work independently from the rest of your system. Have a look at the following architecture: {Database} --> ...
Robert Harvey's user avatar
8 votes
Accepted

How can I move from Web Forms to ASP .NET MVC 5?

You're going to have to embrace ASP.NET MVC in its own right. There is no server code-behind. There are no drag-and-drop widgets, no plugins, and no leaky page life-cycle. There is no almost-wysiwyg:...
Robert Harvey's user avatar
8 votes
Accepted

Am I breaking SRP when I inject Factory pattern with Repository layer?

While in general injecting something is not bad and does not automatically result into breaking the SRP (nor it does in your case - you have one class which only fetches data and another constructing ...
Andy's user avatar
  • 10.4k
8 votes

Any reasons for DTO (ORM autogenerated stuff) model used as ViewModel?

There are no clear standards on how to structure the "M" layer of an MVC application. That being said, I have consistently come across problems with using business classes (or domain models, or ORM ...
Greg Burghardt's user avatar
8 votes
Accepted

In MVC, is the router considered one part of the controller? Or are they considered separate entities?

How to you write the word "computer" in ancient latin language? Nobody knows, because for sure, there were no computers in the roman empire ;-) The MVC architectural model was designed in ...
Christophe's user avatar
  • 78.7k
7 votes

Testing: deterministic or non-deterministic?

Both deterministic and non-deterministic have a place I would divide them as follows: Unit tests. These should have deterministic, repeatable tests with the the exact same data every time. Unit tests ...
Michael Durrant's user avatar
7 votes
Accepted

Application service layer calling database functions. Bad architecture?

Is there any problem in having application services call - directly - database functions? Is not this considered bad practice? I think there is. You are placing a knowledge about the database ...
Vladislav Rastrusny's user avatar
7 votes
Accepted

Why do frameworks give more flexibility to models than controllers?

"Model" in this context (and in the context of MVC, MVP, MVVM, etc.) is not something you use for database access. It is not a data model. It also doesn't refer to "view models" that you may find in ...
Filip Milovanović's user avatar
7 votes

How to deal with too many interfaces

While not entirely in the style of C#, free monad API can help you here. Here's a C# example. In a free monad API, your interface is modeled as objects: // Static DSL for composing DbOp public ...
Samuel's user avatar
  • 9,197
7 votes
Accepted

How to update the view when the model changes?

This depends on the life time of the view. For short-living views, it may be sufficient not to update the view at all. It may be soon enough to display the new model content the next time the view is ...
Doc Brown's user avatar
  • 210k
7 votes
Accepted

What is the correct usage of the IEnumerable interface in C# to deal with collections?

Personally I'd do something like this public class AllProfilesViewModel { public AllProfilesViewModel(IEnumerable<FullUserProfile> allProfiles) { _allProfilesList.AddRange(...
Peregrine's user avatar
  • 1,236
6 votes

How to architecture a realtime-heavy websockets-based web application?

After a few months of work on the backend mainly, I have been able to use some of the advices here to address the problems the platform was facing. The main objective when rethinking the backend was ...
Philippe Durix's user avatar
6 votes

What are the improvements of MVP over MVC?

In MVP, the Presenter replaces MVC's Controller. The difference between the two is that the Presenter directly manipulates the View. It is designed for UI frameworks that are primarily event driven (...
Michael Brown's user avatar
6 votes
Accepted

is it common sense to convert database data to object first?

Honestly, I would add a row mapper or an ORM to the project. Even for developers, to read data in such format (arrays) is tedious and complicated. After a couple hours, the readability becomes ...
Laiv's user avatar
  • 14.7k
6 votes
Accepted

Any reasons for DTO (ORM autogenerated stuff) model used as ViewModel?

From a security standpoint you should use a 1 to 1 view to view model and only pass the properties that the view needs. If you use the full ORM class then a malicious user could manually post extra ...
RubberChickenLeader's user avatar
6 votes

Should the "model" part of MVC deal with the internationalization layer?

In a MVC application internationalization mostly belongs in the views. If a model or a service needs to translate some strings there is nothing wrong with using the internationalization components ...
Esben Skov Pedersen's user avatar
6 votes

Is it acceptable to break MVC by storing data in the DOM in order to reduce load on the Database Server, ever?

One can never trust input from a client, especially sensitive input like prices. If you want to cache information to avoid stressing the database server (did you measure that this is actually an ...
D. Jurcau's user avatar
  • 557

Only top scored, non community-wiki answers of a minimum length are eligible