You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Carlos Rovira <ca...@apache.org> on 2019/04/29 17:04:04 UTC

extending IUIBase with interfaces (was: Re: Version property (was: Let's bump Royale version to 1.0))

Hi Alex,

initial problem is: I want to add to all jewel components (that use to have
UIBase as common class) a new interface and implement the methods. In
concrete interface is: IClassSelectorListSupport

So the expected result should be to make all Jewel components implement
IClassSelectorListSupport, but to avoid repeat code in all classes we need
a root for all the components.

Perfect point would be UIBase, but we can't add at that point for PAYG
reasons.

Current solution in Jewel is to create StyledUIBase that is

public class StyledUIBase extends UIBase
implements IClassSelectorListSupport

but this makes other classes like jewel Group that extend html Group have
UIBase in the hierarchical chain instead StyledUIBase, so we need to make
Group as this:

public class Group extends org.apache.royale.html.Group implements
IClassSelectorListSupport

same for

public class DataContainerBase extends
org.apache.royale.core.DataContainerBase implements
IClassSelectorListSupport

This make we have 3 classes that are duplicating the same exact code
implementing in the same maner addClass, removeClass, etc..

what can we do for this cases?

Hope is more clear now,

thanks



El lun., 29 abr. 2019 a las 17:41, Alex Harui (<ah...@adobe.com.invalid>)
escribió:

>
> @Carlos, I couldn't understand your scenario.  Feel free to start a
> separate thread on it.  The key aspect, as a guess, is trying to avoid code
> that assumes that an instance is a subclass of a particular base class
> instead of an implementation of an interface.
>
> HTH,
> -Alex
>
> On 4/29/19, 7:29 AM, "Carlos Rovira" <ca...@apache.org> wrote:
>
>     @Mark, if you use Maven, then artifacts in the poms are all what you
> need,
>     so maven takes care of pulling all right dependencies you need.
>
>     @Alex, about extending IUIBase, my own experience is that beads are a
> very
>     good way to extend/compose more code you need, but extending core
>     interfaces like the one you said is not the case. Let me put you an
>     example: For Jewel I use "StyledUIBase" that extends "UIBase" to add
>     IClassSelectorListSupport, the css CRUD API (addClass, removeClass,
> etc..):
>
>     public class StyledUIBase extends UIBase implements
>     IClassSelectorListSupport
>
>     This makes that some components are easy to extend but others need to
> be
>     recreate. There are lots of cases in Jewel where I need to
>
>     If you search in Jewel for implements IClassSelectorListSupport
>      you'll find Jewel Group, Jewel DataContainerBase and Jewel Table, are
>     implementing that class while, so they are not StyledUIBase in it's
> core
>     are standard UIBase and at its level we implement the interface and add
>     again all methods repeating the code. So we are duplicating that code
> all
>     that times.
>
>     I think this is one of the few things I don't like in Jewel, If you
> know
>     some way to do this in a better way, I can change it
>
>     thanks
>
> --
Carlos Rovira
http://about.me/carlosrovira