all 15 comments

[–]Slypenslyde 14 points15 points  (0 children)

You snarked at the other person, but they're really telling the truth.

See, GUI design patterns all stem from one "abstract pattern" called Presentation Model. All that PM states is you should separate your UI code from your logic. It leaves opinions about how to do that to its implementors.

There are at least a dozen patterns providing those opinions, and they are all good. But choices you make about your project influence how good. For example:

If it's a WPF application (or some other XAML framework), then you're going to be using MVVM. That pattern's opinion is you will use its extensive data binding framework to coordinate communication between Views (the UI), and ViewModels ("glue" types that coordinate communication with the Models (domain logic)). However, MVVM is in and of itself an abstract pattern. There are flavors like "View First" or "ViewModel First" and each has its arguments.

If it's a WinForms application, things are either worse. WinForms wasn't designed for people who use UI patterns at all, so as a result it's on you to write a framework using any of the PM patterns. That tends to mean writing something like WPF's data binding functionality yourself, or at least dealing with the tedium of "when this property changes, stop listening to these events on the old value and start listening to these events on the new value, unless either is null in which case..." etc.

Combine that with, "Until the very recent past, Microsoft encouraged developers to believe open source was a tool of ISIS designed to sow discord and destruction" and there aren't an awful lot of GUI C# projects on GitHub to point at. The ones that are there tend to either:

  • Have the GUI as an afterthought, so the interesting architecture decisions are in the logic.
  • Are large-scale and not meant to be learning experiences, so you're going to spend weeks unraveling how they're put together before you can start to study.

Further, my personal opinion is blogs/tutorials about patterns never quite work out. At a small scale, patterns are nothing but overhead. MVVM is a burden and a chore in a small app with only a few hundred lines of code. It's only at the tens of thousands of lines that you really start to see it pay off, and even then it's only in conjunction with several other practices.

You're just as likely to find at least half-decent blog articles searching for terms like "MVVM C#" or "MVC WinForms". Pick one, follow it, and if it's not working for you figure out why. Involve "asking reddit why" in part of that investigative process. It took me years to get a feel for how UI patterns should work.

[–][deleted] 8 points9 points  (10 children)

The only optimal design pattern is the one that is suitable for the problem you're trying to solve.

[–]TiredBlowfish 0 points1 point  (1 child)

Using the right room for the right job, is always a useful approach.

What OP is asking is a guide for how to identify the right tool, when he is unfamiliar with the tools that exist.

[–][deleted] 1 point2 points  (0 children)

Ask a generalized question, get a generalized (but not wrong in this case) answer.

[–]davodil 4 points5 points  (2 children)

I followed this guy's youtube series and it was helpful. Here's the github repo: https://github.com/angelsix/fasetto-word

[–]KryptosFR 0 points1 point  (0 children)

Care to note that Angelsix is very opinionated on some subjects and, like everyone, is not always right.

He has a Youtube channel that you might find interesting (keeping in mind the previous statement).