Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Humble dialog vs MVC

Why should I choose to use one instead of the other and in which cases?

I mainly focus on desktop applications and personally speaking I do find the humble dialog box more easy and natural to use.

like image 509
Yorgos Pagles Avatar asked Oct 23 '08 10:10

Yorgos Pagles


4 Answers

In MVC, you would still use your "humble" dialog. Except all the business logic for it would be farmed off to another class somewhere else.

http://en.wikipedia.org/wiki/Model-view-controller

You need to weight up whether the investment in MVC will be worth it - especially if you're only working with a single simple dialog.

like image 83
Mark Ingram Avatar answered Nov 10 '22 08:11

Mark Ingram


One of the best discussions I've found regarding the advantages and disadvantages of the model view controller/presenter patterns was written by Martin Fowler: http://martinfowler.com/eaaDev/uiArchs.html

In short, by choosing to use a MVC variant you are increasing the testability of your view (dialog). Keeping all of your logic in your dialog class on the other hand, can be fine if you do not expect that dialog to be very complex, however as the complexity increases, the benefit of testable code increases.

It really is a judgement call.

like image 32
Jim Burger Avatar answered Nov 10 '22 09:11

Jim Burger


"Humble" dialogs themselves are already MVC. You have:

  • M, The content of the dialog's message.
  • V, The window and widgets the user can see.
  • C, How the dialog is displayed and how it responds to user activity.

Your GUI framework or wrapper library can provide MVC for you seamlessly without you having to think about it, but it's still MVC.

like image 24
Ali Afshar Avatar answered Nov 10 '22 08:11

Ali Afshar


There is no simple answer.

You should use whatever will make your life easier.

If dialog is really simple, and you know for sure it is going to stay that way, go with humble dialog.

If you have something more complex, like multiple view presentations of the same data, or you know your simple dialog will become more complex over time, then, by all means, use MVC.

You can also take a look ant MVP pattern as an alternative to MVC.

like image 32
Marko Avatar answered Nov 10 '22 08:11

Marko