Reputation: 2465
I'm working on .NET 3.5 form application with slightly complicated behaviour. It's for a book inventory. To give you an idea, a workflow would be:
That's four responsibilities:
My question is: Should I keep the application logic in one MVP-structure or should I split it into four MVP-structures, one for each responsibility?
Keeping it in one MVP-structure would
Keeping it in separate MVP-structures would
I'm trying for the Presenter First-principles, so: - Keep the view dumb (so no events like "Presenter one validated the ISBN"), - Keep the presenters stateless, - Keep the models simple (enough)
Anyone has an idea on what's the best way to do this?
Upvotes: 4
Views: 426
Reputation: 32698
I would go with one Presenter but delegate the validation etc of ISBN numbers to a Service.
Something along these lines in the presenter to handle an ISBN being entered:
public void IsbnEntered()
{
var isbn = view.Isbn;
if (isbnService.NumberIsValid(isbn))
{
var details = isbnService.RetrieveDetailsForIsbn(isbn);
if (details != null)
{
view.Display(details);
view.EnableSaveButton();
}
else
{
view.DisplayError("ISBN could not be found");
}
}
else
{
view.DisplayError("Invalid ISBN");
}
}
Here the responsibilities are well defined. The IsbnService is responsible for ISBN handling, the View for display and input retrieval and the Presenter manages the interaction between the two.
Upvotes: 1