Hi guys,

I've encountered an interesting pattern while working on a recent patch: some 
View classes actually embed other View classes, and add those embedded Views to 
the (top-level) View.

For example, ImportVmPopupView has a field "ImportVmGeneralSubTabView 
generalView", which is created as part of constructor and added to 
ImportVmPopupView's layout.

The bottom line is, please don't use this pattern. Views are architectural 
components in Model-View-Presenter which are living in a particular scope (e.g. 
singleton/non-singleton), so UI composition should be always done on Widget 
level, instead of View level.

In other words, ImportVmPopupView shouldn't embed ImportVmGeneralSubTabView, 
but instead embed UI (Widgets) similar to ImportVmGeneralSubTabView. In case 
embedded View's UI is complex, we can just create a reusable widget that would 
be used in both ImportVmPopupView and ImportVmGeneralSubTabView.

Otherwise, we could run into problems, especially since ImportVmPopupView is 
dialog-specific (non-singleton) and ImportVmGeneralSubTabView is 
sub-tab-specific (singleton). In Model-View-Presenter, View != immediate 
Widget, View == MVP component wrapping UI (Widget) and bound to a specific 
scope, so that's the reason why UI composition should be always done on Widget 
level (on the other hand, subclassing Views is perfectly OK).

Sorry for being police man here .. it's just a note to keep in mind for future 
:)

Regards,
Vojtech
_______________________________________________
Engine-devel mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-devel

Reply via email to