Hot answers tagged

65 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
  • 134k
43 votes
Accepted

Clean Architecture - Too many Use Case Classes

Do I really have to make 24 use cases? Only if everything you write is CRUD. Refer to the diagram below: Your assertion is that you will have six different entities, and 4 methods (Create, Read, ...
Robert Harvey'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.7k
16 votes
Accepted

What is the difference between MVP and clean architecture

What Bob Martin called "Clean Architecture" is more a "meta architecture", a high level guideline for creating layered architectures. It does not say anything like "There ...
Doc Brown's user avatar
  • 203k
12 votes
Accepted

Who communicates with the database in MVC/MVP?

I've seen it done two ways. The first way is to do everything using CRUD methods. That's essentially the way you are describing: Create, Read, Update and Delete. Most Object-Relational Mappers (ORM'...
Robert Harvey's user avatar
8 votes
Accepted

In MVP pattern should the View instantiate a Model object based on UI contents, or just pass these contents as parameters to the Presenter?

According to Martin Fowler's description of MVP ( http://martinfowler.com/eaaDev/uiArchs.html ) Of the View portion of MVC, Fowler says: The first element of Potel is to treat the view as a structure ...
Ben Cottrell's user avatar
  • 11.7k
7 votes
Accepted

MVP (Supervising Controller) Does the view update the model?

There are several variants of the MVP around since its original design in 1996 by Mike Potel. Martin Fowler discusses some of them in another article on GUI architecture. One of the key differences ...
Christophe's user avatar
  • 75.9k
7 votes
Accepted

How many presenters should I use in proper MVP?

Making the Presenters be dependent one one another does not sound right. The dependencies are such that you will need all the Views and all the Presenters to make one pair of View and Presenter work. ...
R Sahu's user avatar
  • 1,986
7 votes
Accepted

Model View Presenter pattern with passive view. Who is responsible for setting the labels' texts?

Both ways will work, so they are both correct. And none of them is "better" in general, the first one is simpler, but the second one allows some things the first one does not, so you have to analyse ...
Doc Brown's user avatar
  • 203k
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

In MVP, should we call repositories from the Model or the Presenter?

In my experience it depends on who you ask (but it shouldn't). I've seen your question asked about MVC, MVP, and MVVM. There is confusion about all three. But why is that? This is mainly the ...
MetaFight's user avatar
  • 11.6k
5 votes
Accepted

In MVP, should we call repositories from the Model or the Presenter?

In an MVP model, the presenter acts as middleman between the view and the model. In consequence, from the presenter you shall call the model and not short- circuit it by calling repository directly. ...
Christophe's user avatar
  • 75.9k
5 votes
Accepted

In the MVP pattern, the Presenter must control the call flow of Model methods?

The method could be part of the presenter, it could stay in the model, or it could be moved to a separate helper or controller class. None of these placements is always "better" or "best practice". ...
Doc Brown's user avatar
  • 203k
5 votes
Accepted

Good analogy for MVP and MVC patterns?

There are 3 main variants of the same basic pattern: Model-View-Controller: The granddaddy of them all. Originally defined with Smalltalk Model-View-Presenter: Variant created primarily to deal with ...
Berin Loritsch's user avatar
5 votes
Accepted

Passing data through events to adhere to the Tell-Don't-Ask principle?

But, I see nobody using code like: public event Action<object, string, string?>? SearchInAlbums; Instead, they all use: public event EventHandler SearchInAlbums; //or something similar By ...
Doc Brown's user avatar
  • 203k
4 votes

In the MVP pattern, the Presenter must control the call flow of Model methods?

Leave createRoom in the model. Throw MVP out the window for a minute, and look at this list: {createRoom, displayRoomToUser, addUsersToRoom, joinRoom}. Which method isn't like the others? Obviously ...
Emmett Casey's user avatar
4 votes

Is 20 Java classes for just making a REST call too much?

Is 20 Java classes for just making... This is entirely the wrong question. Something is wrong or you wouldn't be asking. It sounds like you're looking for something to blame. Anguishing over the ...
candied_orange's user avatar
4 votes

Is it bad practice to have calculations in the Presenter/Controller and View

"Best practice" is usually short hand for "whatever matches my prejudices". It's not an objective evaluation, and specific cases may require a departure from best practice... So, here are my ...
Neville Kuyt's user avatar
4 votes
Accepted

In MVP, should the View have access to Domain objects?

The key principle in the MVP architecture (initially introduced by Talligent in 1996), is that the presenter acts as middleman between the view and the model. The underlying idea is that in a client-...
Christophe's user avatar
  • 75.9k
4 votes

Clean Architecture - Too many Use Case Classes

You are right if every CRUD-Operation is translated in one UseCase. But a UseCase may also consist of multiple CRUD-Operations. A UseCase is a separated model gathers information from different data ...
oopexpert's user avatar
  • 769
4 votes
Accepted

In MVP, should the View expose the controls themselves or just their values?

Creating automated tests for your components will be much easier if you code to interfaces (instead of concrete classes) of the model and the view. Now rethink your question: do you want to expose the ...
Hero Wanders's user avatar
  • 1,077
3 votes

I have a few questions about the MVP pattern in a WinForms project

Is a form a View?/ Can a form be a View? Which derives from a IFormView class Yes. Precisely. Does each form have their own Presenter? If not, how is this organized instead? That is ...
RubberDuck's user avatar
  • 8,931
3 votes

PHP MVC/PAC - Logged In/Admin checks placement

Authentication should happen after routing but before calling controller or its methods. At that point you know which route was requested and can check if user has privileges to perform a certain ...
potfur's user avatar
  • 479
3 votes

A proper way to work with MVC

I'd seriously recommend looking into viewmodels. How the data is presented in the database isn't always how you'd want it presented in the UI. A common example is prices - where it might be stored as ...
Robbie Dee's user avatar
  • 9,737
3 votes
Accepted

Why are interfaces necessary in MVP design pattern?

Interfaces are required in good quality implementations of MVP for the same reason they are required in all good "OO" designs: They help reduce coupling They discourage inheritance (which further ...
David Arno's user avatar
  • 39.1k
3 votes

Is it bad practice to have calculations in the Presenter/Controller and View

It is preferable to do this calculation in the domain model. Developers often overlook plural business entities... ProductCollection.TotalPrice With that said, I don't think it's bad to do a simple ...
TheCatWhisperer's user avatar
3 votes

In the MVP architecture, how should the Model layer get its data?

The MVP pattern basically separates the model, from a view through a presenter. Here, the presenter listens for any user interaction through the view. The presenter then fetches the relevant info from ...
Navneet Krishna's user avatar
3 votes
Accepted

Should the presenter access view data via properties or event parameters?

The event data approach will keep you a little closer to the observer pattern, but you should probably not create (or instantiate) Employee from within the view. It's almost like you're directly ...
Silviu-Marian's user avatar
3 votes

Clean Architecture - Too many Use Case Classes

It's assumed that clean architecture is used in business heavy applications, where use cases are mapped to business rules. In a CRUD app it's over-engineering. Here you can use facade and map requests ...
photostok's user avatar
3 votes
Accepted

Question on MVP Pattern, Events and saving complex objects

I would segregate the persistent data to DTO's that are consumed and produced by full blown long lived objects that were taught what handlers existed were when they were constructed. Done this way ...
candied_orange's user avatar

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