This project has moved and is read-only. For the latest updates, please go here.

Controller getting too big...

Nov 16, 2010 at 12:16 PM
Edited Nov 16, 2010 at 5:10 PM

Hello everybody,

I'd like to hear your opinion about over-sized controllers.

I checked out the BookLibrary sample. The LendTo functionality is quite simple and I understand why all the needed implementation was put inside the BookController.

However, I'd like to know what would you do if the LendTo feature was somehow more complex: for example, let's say that from the LendTo form has to be possible to open another form for the creation of a new "Person", or let's say it should be opened a new form to perform some lookup and return the value to the LendTo form... how would you modify the existing architecture to fit within the new requirements? I wouldnt like to put everything inside the BookController; I was thinking it would be better to have a separate LendToController... and here is my actual question: how to do it? When this new controller instance should be created? and how? I guess it shouldnt be shared but it should be created just for the purpose... 

Could someone help me to find a good approach to solve this problem please? Some guideline would be more than enough, and absolutely appreciated. 

Thanks in advance,

Cheers,

Gianluca.

Nov 16, 2010 at 8:23 PM

Hi Gianluca,

I agree that a Controller shouldn’t grow too big. When this happens a Controller can delegate some of its work to sub Controllers (e.g. LendToController).

The ViewModel (EmailClient) sample of the WPF Application Framework (WAF) shows how this can be accomplished. Please have a look at the CreateEmailAccountController which is created by the ApplicationController when the user wants to manage his email accounts.

jbe

Nov 24, 2010 at 9:27 PM

Hi jbe,

Sorry for replying to your post after so long. I followed your advice and everything looks just great!

Thank you again,

Cheers,

Gianluca.

PS: WAF is great, congrats for your work!