-1

I am going to develop a simple desktop app (a basic crud with a tiny database) in C#, I don't know which pattern to use. In this case, which one would be the right one? Those are the patterns that I know:

  • MVC
  • MVP (model view presentation)

Thanks a lot

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
canemarcovaro
  • 23
  • 1
  • 3

2 Answers2

3

Don't use patterns if the application is really gonna be small. Just follow SOLID principles as much possible. Don't overengineer ! Patterns like MVC, MVVM, MVP.. are architectural patterns, which make sense in medium to large scale systems.

Stefan PEev
  • 481
  • 5
  • 17
-2

There is no right answer for you because it will depend on several things, such as the lenght of the application, your expertise in c#, the kind of desktop app as another user pointed out. That being said i will give you some tips.

  1. First of all, MVC is a web oriented pattern, which aim is to improve cohesion between classes and have a clearly responsibility for each of its components. The view, does interact with the controller through requests, and the controller interacts with the model which interacts with the repository in order to generate a response for the client basically. So provided that you want a desktop app, this is a no go.

  2. MVP pattern is the same pretty much the same (not really know it but i know its a derivate from the MVC pattern), but the presenter is the one that interacts with the model through interfaces, perhaps this is what you want since it can work with a win forms.

Those are my thoughts on the patterns you just mention, but i ll add something i work with.

I dont know the name of the pattern but i usually work with a layer structure similar to mvc but its not a pattern per say i think (i would gladly know if it its and please point it out in the comments). I work with basically 4 layers: Presentation, Data, Logic, Model. The responsibilities are, The presentation is the one that interacts with the user, whenever the user sends an input and it needs to interact with the repository you are using, you do it through the Logic layer, which has your business logic, then there is the Data logic, which is your repository basically, it doesnt know anything of how the data is rendered, it just knows that it needs to do CRUD operations on your repository.

In spite of what I said, you are saying you need a simple app, patters are a great work to build scalable apps, but it can take some work to set them up, and if the work you need to set them up overseeds the needs you have for your app then you are maybe poking the wrong tree here. And you basically can have all in 3 or 4 classes, dont try to make your program fit a pattern, they are to make our work easier not harder.

nalnpir
  • 1,167
  • 6
  • 14
  • 3
    You couldn't be **more wrong** in your descriptions of MVC and MVP. MVC a web-oriented pattern? So I guess that no programming language existed before C# and that Microsoft invented it, right? No, completely wrong. At least familiarise yourself before answering: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller. Besides that, you start by saying "There is no right answer", so if there is no right answer this question is not suited for Stack Overflow. – Camilo Terevinto Jul 05 '19 at 12:35
  • There are lot of programming languages that uses the MVC pattern for web developmnent, just not as much that uses for desktop apps, as a matter of fact i know no one that uses mvc pattern for dektop apps, there are variations of it that use them like MVVM, MVP or some other patterns. Who said anything about c#, i said web programming, you can use whatever language you want, such as ASP.NET or RoR or perhaps using python with flask – nalnpir Jul 05 '19 at 12:40
  • 1
    You didn't understand what I commented. The pattern was born to solve desktop programming problems, that it then turned into a web architecture is completely different – Camilo Terevinto Jul 05 '19 at 12:42
  • I do know that the pattern solves cohesion and separation of responsibilities as i stated, perhaps you are right about it not being at first to web development, but we are talking about starting a project today, i want to think that we evolved to the point were that pattern might be used but there is no point to use it in desktop applications. That being said you are right, i was wrong to think it was only for web dev only. And about the "No right answer" thing. There are multiple approachs to a problem, you just have to work a solution that you can take with the resources you have. – nalnpir Jul 05 '19 at 12:46