-1

A PySide project I've been working on for a while now has started to grow to a point where it's becoming large enough that I've had to step back and re-think the overall design.

I've spent some time with both Flask and Django, so I'm familiar with the MVC design pattern conceptually, but had the advantage (or maybe disadvantage!) of so many great examples of how to structure and layout Flask/Django projects that I didn't really have to give it a lot of thought. Now that I’m trying to slot my own project into this type of design pattern for the first time, I’m finding it tough to envision how everything should be laid out. Spending some time reading about the MVC pattern I was a little pleased to see that I had partly gone down that path without consciously trying, but had made things unnecessarily complicated and coupled.

There is nothing particularly special about my program – a user interacts with a UI which retrieves data from a database for either viewing or processing.

Trying to map this to a MVC structure, I came up with:

Controller: Most of the actual application functionality – user interacts with a widget on the UI, the controller takes this input and actions the appropriate operations – retrieve data from the model and send it to the View to display on the UI, run operations on it and send back to the model to update in the database, etc. In Qt speak, widget signals connected to Controller methods involving pulling data from the model (usually) for processing, or view via the View.

Model: Insert/updates/selects data from the database as directed by the Controller.

View: The actual UI work is done here – updating widget stylesheets (core function of the program) and also formatting data passed to the View by the Controller (from the Model) as specified by the Controller (taken from various options the user has selected on the UI) to then display to the user via display widgets. This is where most my individual object classes would come into play.

The main difference between what I’ve listed above and how I’ve been structuring my program currently is the Model/View components were more or less overlapping, with the Model retrieving data but also doing most of the formatting of the data as well.

So, am I on the right track here?

closed as too broad by Doc Brown, Ixrec, GlenH7, user40980, Wayne Molina Jan 29 '16 at 20:25

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

-1

Yes, you are on the right track. Especially if you remove all presentation/formatting logic from the Model into the View.

  • Thanks Bart. It was encouraging to see that as soon as I started restructuring my code a little to fit the above, a couple of issues I'd been having were resolved. – Groundhog Jan 22 '16 at 4:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.