This project is read-only.

Regarding controller cache

Dec 9, 2008 at 11:03 AM
I was wondering if this feature is really working because the way i see it: if the controller has been created before then use its reference or else create an instance of the controller.

Analysing the code, more specifically in the NavigationService, the Navigate methods, each one has a parameter type of Controller, meaning it's using a reference of a Controller object.

On the sample project (for example) in the SearchController class, before calling the NavigationService.Navigate method, there's always a Controller object creation which creates the view (Form), using processor time and memory space..

Shouldn't the NavigationService somehow check if there is a Controller of a type, and if positive use its reference or else create there a new instance of the Controller object?
Dec 9, 2008 at 7:12 PM

Hi Gonçalo,

NavigationService aslo has Navigate method that accepts the name of the Controller, which will get the Controller from the cache. The reason NavigationSerivice can't create an instance is the existing dependency on the View which is currently injected via constructor. Unless we make NavigationService to also have functionality of the IoC and DI container. The initial idea was that a developer would use the NavigationService.Navigate(Controller controller) method the first time and then he/she could use Navigate(string name) or GoBack/GoForward to show an appropriate view.

Thanks... Alex

Dec 10, 2008 at 10:12 AM
Hi Alex,
 
So based on the initial idea, the developer must know when to use Navigate(Controller controller) and Navigate(string name) methods.
The IoC and DI idea would be very nice.

I have just a sugestion for the NavigationHistory, it's just a small point.
Would the user be able to Navigate to a Controller which in the NavigationHistory is the current Controller?
If so, then the NavigationService would do a Controller refresh instead of adding another controller to the NavigationHistory.

Gonçalo
Dec 10, 2008 at 3:26 PM
>The IoC and DI idea would be very nice.

I've got some prototypes working. Will try to find some time to implement it.

>If so, then the NavigationService would do a Controller refresh instead of adding another controller to the NavigationHistory.

Yeah... you've got something here. I will change the code to remove the existing controller from the cache.