pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alejandro Vilar" <alejandro.vi...@synacom.com.bo>
Subject RE: Constant Interface Antipattern
Date Thu, 22 Apr 2010 08:06:29 GMT
Hi Dirk,

>Then you would need one Adapters class for each package. I like the  
>way Pivot does it better, because I see that an adapter is available  
>immediately by looking at the interface.

I like the Pivot's way in too many cases, but when is related to interfaces
with body...
About the Adapters class I was talking about this:

package org.apache.pivot.wtk;
public class Adapters{
    public static class ComponentListenerAdapter implements
ComponentListener{
 	//...empty implementations
    }
    public static class ComponentMouseListenerAdapter implements
ComponentMouseListener{
 	//...empty implementations
    }
    public static class ComponentKeyListenerAdapter implements
ComponentKeyListener{
 	//...empty implementations
    }
 }
I agree with you about the adapter availability and quick search, but there
it not much difference using Apaters.*


>Contrived. Why would you name your sub-sub-class exactly the same as  
>the Adapter class itself? Usually subclasses get a different name to  
>signalize their special behaviour.

You right too, but I was pointing the inclusion of possible undesired names
as the Constant Interface Pattern do. Well, that kind of inheritance was an
example, but what if I use a Delegate pattern in my AbstractAdapter:

package example;
public abstract class AbstractAdapter implements Foo {
   private Adapter delegate;
}

Another example:
public class Adapter implements Foo {
    static void test() {
        Adapter adapter = new Adapter();//Points to Foo.Adapter class (not
really desired)
    }
    //...contract implementations
}

I'm concern only-and-only in Foo interface and my class Adapter (name which
I'm obstinate to use to show my point :P).

The last class in the inheritance hierarchy doesn't need to adapt his
class-naming-convention based on what "tools" are used in super classes.

Also using names like AbstractPerson, Person, Contact are not really rare.

Anyway, I don't want force any thought, originally was an simple
observation.

Cheers,
Alejandro

-----Original Message-----
From: Dirk Möbius [mailto:dmoebius@scoop-gmbh.de] 
Sent: Jueves, 22 de Abril de 2010 02:59 a.m.
To: user@pivot.apache.org
Subject: RE: Constant Interface Antipattern

Alejandro Vilar <alejandro.vilar@synacom.com.bo> wrote:

> public class Adapters{
>    public static class ComponentListenerAdapter implements
> ComponentListener{
> 	//...empty implementations
>    }
> }

Then you would need one Adapters class for each package. I like the  
way Pivot does it better, because I see that an adapter is available  
immediately by looking at the interface.

> package other;
> import example.AbstractAdapter;
>
> public class Adapter extends AbstractAdapter {
>     public void bar() {
>         System.out.println("Subclass implementation");
>     }
>     public static void main(String[] args) {
>         Adapter adapter=new Adapter();
>         adapter.bar();
>     }
> }

Contrived. Why would you name your sub-sub-class exactly the same as  
the Adapter class itself? Usually subclasses get a different name to  
signalize their special behaviour.

Dirk.




Mime
View raw message