Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: UI component decoupling  (Read 6142 times)
paulv410
Newbie
*
Posts: 3


View Profile Email
« on: September 18, 2008, 04:59:04 »

Is it bad practice to require that a view (UI) component implement a particular interface?

We have a framework which is going to be used by multiple applications.  The applications will decorate a base visualization component (table, pie chart, etc) from the framework with menus, etc.  The framework retrieves the decorated component from the application through a proxy which acts as a factory.  Currently, the factory just returns a DisplayObject.

In order for the framework to create the correct type of mediator for the base component, the framework must know what type of base component is being decorated.  (There needs to be a different mediator for a line chart vs a pie chart).

Our idea is to require that the decorated component returned by the factory implement an
interface which returns our base component.  We can then create a mediator based on the type of base component.

Our concern is that this will make the UI component less portable since it now must implement this interface.  Does this seem acceptable or is there a better way to do this?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: September 19, 2008, 04:56:08 »

Nothing wrong with making the view component implement an interface. If you were stripping these components out of your PureMVC app and say, migrating it to Cairngorm, you'd probably still use the same scheme you'd just put the factory in a different place, right? So portability isn't really an issue. However the 'proxy as view component factory' isn't the best concept. This factory has nothing to do with the model, and by placing this UI factory code there, you make the model less portable. If you were re-using this model in another app with a completely different UI, then this factory would be an unwelcome inclusion in that app. This is controller region code. A command would be a better place for the UI factory.

-=Cliff> 
Logged
paulv410
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: September 19, 2008, 05:20:02 »

Great!  That makes sense.  Thanks for your help.
Logged
Pages: [1]
Print