Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to structure a project in Winforms using MVP pattern? [closed]

I intend to build application with Winform and I would like to use MVP pattern.

Since I have never used MVP pattern before, I am not sure how to structure the new project.

Should I use same convention as in ASP.NET MVC like creating in the project separate folders for Models,Presenters and Views, then maybe using naming convention for Presenter classes so that their name ends with word "Presenter" (the same way the names of controllers in MVC end with "Controller")

Or should I create separate projects for Presenter and Model?

like image 604
user850010 Avatar asked Apr 25 '12 17:04

user850010


1 Answers

Honestly, this is a very subjective question. The way I am doing this today may not be the way I do this for the next application. It simply works out well for me. Also, what works for me may not be the way anyone else would do it - not that mine is wrong, better, or worse.

Naming conventions will help:

  • PersonPresenter
  • PersonViewModel (if data is read/write to data store)
  • PersonView
  • IPersonView

Also, I have separated my current solution into 3 projects:

  • The app itself - the only class in that project is Program.cs
  • Presentation Models: presenter, view interface, view model (if applicable); all in folders organized by their respective views
  • Views: a project just for the views

Now, the only piece of the solution that I need to reference for unit testing is the PresentationModels project.

like image 73
IAbstract Avatar answered Nov 10 '22 12:11

IAbstract