View Factory

Topics: CAB & Smart Client Software Factory
Apr 28, 2006 at 6:38 AM
originally posted by: binaryrefinery

Hi All,

Please forgive newbie-style questions and mistakes in this post... I've recently been introduced to the world of CAB and the M-V-P pattern and am still climbing the learning hill.

As far as I see, one of the ideas behind having a IMyView interface is so that the UI implementation becomes decoupled from the rest of the system (workitems, presenters etc.), however in most of the examples I've seen, the view is instantiated directly by the workitem (via .AddNew(of MyView)()). I know that after this line, we should only deal with IMyView, but how about abstracting the creation of the concrete view class?

I was thinking along the lines of a "VewFactory" service... you pass it the type of view interface to create and it reads a config file to determine the concrete class to create and return. This hopefully would allow for an easy swap of UI implementation with no code changes (e.g. To run a test harness interface or make a switch from WinForms to WPF).

Ideas, suggestions and "point-me-in-the-right-direction" help is much appreciated.

Apr 28, 2006 at 8:20 AM
originally posted by: binaryrefinery

Ok.... upon further research, it seems that this may be possible with the object builder.

From the Docs:
"ObjectBuilder encapsulates features that simplify the creation of object instances. It can:
- Ensure the creation of specific concrete class instances, even when requests are for abstract types"...

I'll see if I can apply this to the View scenario... in the meantime, if anybody has any ideas, I'd be very grateful to hear them.