Class Diagram

OK... I am attempting to implement a simple MVC windows application...

There is a helper class (ConvertPDF) that is instantiated by the Controller.

As it is currently implemented, the Converter directly updates the View and the Model. I have an inner feeling that this is just bad form! I have included these two associations in the class diagram.

Should the Controller be notified that ConvertPDF has finished? Once the Controller knows this, then it is responsible for updating the View and the DataSet.

If this is the preferred approach, can anyone direct me to some examples. I imagine there will be events and delegates involved.



2 Answers 2


In general the Controller should update the Model, which is mapped to the View

It looks like you've gone a bit off track, Mixing your Model and Controller into the Album class.

Although this is good OOP for MVC you should add an extra controller class where you put the logic for button presses, events etc. ie

     //trigger non business logic event
     this.ViewModel.ShowProgressBar = true
     this.ViewModel.AlbumData = this.Album.Data
     this.ViewModel.ShowProgressBar = false

If you keep Business logic methods on your Album object then possibly you could add another AlbumViewModel class to bind the view to. This can simplify your Business Model Graph if its not a 1-1 match with the view.

Exposing a low level object like a dataset as a Model isn't a great idea, unless you view uses a component which directly consumes it, say a graph or grid. Even then you are probably better off with an object, as you will want extras such as xAxis legend, sortedByCol etc

My advice would be to start afresh with a new AlbumViewModel class. Put everything the view needs on it. Then make a new AlbumController class, add your business models and extra logic there, work out how to create the View Model when the events happen.

Once you have those named objects, you can trim things back and decide where you want the various bits of logic to go. Business Model or Controller.

Never touch the view directly. That should all be done by binding (you dont say what framework you are using?)

  • Thanks for your full and prompt response. I am now even more confused! The class Album, I hope, is the Controller. How is the function of the Model mixed in here? My poor understanding is that the Controller contains the GUI logic, which then is presented in the View. What would a new AlbumViewModel class do?
    – Oscar
    Mar 31, 2017 at 7:54
  • Model, which is mapped to the View..... Does this imply the View is not linked at all to the Controller? OMG I really have misunderstood MVC
    – Oscar
    Mar 31, 2017 at 7:56
  • yes. but obvs there is a link behind the scenes. what framework are you using? c# wpf? asp mvc?
    – Ewan
    Mar 31, 2017 at 14:55
  • @Oscar I've occasionally seen misguided articles/blogs advocating logic in a Controller, but that really isn't what a Controller is for; a Controller has one role which is to create and inject the Model (a.k.a ViewModel a.k.a. Model-of-the-View into the View itself). The important take-away with regards to MVC, MVP and other MV* patterns is they are GUI patterns, and therefore don't cover business logic or business models at all. Controllers may call into a Business Logic Layer to pull data used for creating a ViewModel, but Business Logic itself is not part of MVC. Mar 31, 2017 at 17:09
  • hmm you have to be careful when you try to say what MVC is. Originally the controller referred to the mouse or keyboard and the in the first asp mvc entity framework was the M, razor was the V so yeah your controller had all the logic. With a windows app now though MVVM seems to be all the rage
    – Ewan
    Mar 31, 2017 at 17:36

the converterPDF class should return the result of it's calculation to the controller and the controller updates the model. the view should be observing the model for changes (Observer design pattern) and get updated when the model changes.

  • So the view directly observes the model? So must be a connection between the two. I have been under the impression that the Contoller must act as an intermediary between the Model and the View.
    – Oscar
    Apr 2, 2017 at 11:50
  • first of all there isn't a single MVC as it adaptes with the environment, in web environment for exemple it's very hard to make the view on the client side observe the model on the server side so in this environment the view doesn't observe the model directly, but in desktops applications it is possible and easy. use the observer design pattern where the model will be the observable and the view is the observer
    – Abdou
    Apr 3, 2017 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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