1

I am developping a desktop application in C#, and have separated different layers in an MVC-ish architecture.

As I have switched from GTK# to XWT, only views had to be adjusted, so the seperation of layers was done quite OK.

As XWT does not have a layout designer, everything has to be set up in code, which in turn led to an architectural problem:

I have one controller for displaying outlets, inlets and connections.

This controller sends data to one view (outlined in red). This view in turn has subviews (green and blue), that only communicate with the view in red.

Layout of view

On scrolling / collapsing / expanding the treeviews, the green view send events, which are received by the red view, which in turn trigger redrawing in the blue view.

Controller does not see the green or blue views, every change in connections / outlets / inlets are only sent to the red view.

My problem: As I understand MVC, views should not have much logic. But the green views is a class of 300 lines, the red view's class has 200 lines, which is too many.

What architectural problem can arise from this? Am I overlooking a fault in my MVC logic?

4

The MVC design pattern was originally formulated in the old days when MS-DOS was still a dominant OS. In those days there was very little support from the OS for graphical user interfaces, so you had to do most of it yourself. In the original MVC, the job of the Controller was to figure out which text-entry field was active and what it meant if the user presses a key.

In the modern desktop OSes with display managers and feature-full widgets, that Controller role has effectively been merged into the View components and the MVC Controller has been given a more high-level coordinating role.

The logic in the Views should indeed be limited, but it should be limited to UI-related logic. For a View as complex as yours, even the UI-related logic can be quite significant, so I don't see any problems with your architecture.

2

Straight forward, I think MVC is not a very good way to design a desktop application in C#. (given C# AND desktop application implying that dot net framework including wpf is allowed).

The most valued and best way to design a desktop UI in C# is the MVVM pattern.

MVVM, meaning Model-View-ViewModel has the most direct support from C# UI features and everything seems to just be made for MVVM.

The structure is just little different from MVC. There is no controller part. (Controller in the sense of MVC formerly was only a way of handling e.g. user input events)

In MVVM you get a three-layered architecture

You have a Model (domain objects, database access, repository pattern, ...)

ViewModel (some kind of mediator between view and model, handling selected item, translating text, ...)

View (this is just what the user sees and nothing more, no logic here except simple conversion to the user desired format of strings etc)

Please investigate on MVVM. There is a fantastic video showing the core techniques by Jason Dollinger on lab49, which can be found here. It is always worth investing that one hour.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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