jpatterns.org

5 views
Skip to first unread message

Dr Heinz M. Kabutz

unread,
Sep 3, 2010, 4:43:48 AM9/3/10
to mirosl...@tuke.sk, jaroslav...@tuke.sk, jpat...@googlegroups.com, Nabeel Siddiqui
Hi Miroslav and Jaroslav,

I read with interest your paper on adding constraints to patterns annotations.  When Michael Hunger and I were searching for patterns annotations, we did not find anything actively being developed on.  Fortunately Nabeel contacted us today and also pointed out your interesting paper.

How much are you able to cooperate with us on developing useful annotations?  Our first attempt of defining annotations was quite similar to yours, with enums holding the roles of each component of a pattern.  Michael Hunger however had the brainwave of defining each component as a separate inner annotation, which makes the annotation more readable.

For example, to define the abstract factory in your paper, we would just say:

@AbstractFactoryPattern.ConcreteFactory
public class AfricanFauna extends ContinentalFauna {
  private static int lionCount = 0;
  @AbstractFactory.ConcreteMethod
  public Carnivore createCarnivore() {
    lionCount++;
    return new Lion();
  }
  public int getLionPopulation() {
    return lionCount;
  }
}

(by the way, lionCount would be better as non-static or otherwise an AtomicInteger).

The benefit with our approach is that you could then document your constraints in the annotation itself, without having to mark up where it is relevant.

Your idea of an int id is interesting, but would not work for us, as it would be impossible to keep the number unique on a large project.  What we do is mark up who the participants of the pattern are.  A tool could then deduce the relationships.

You can see our work here: http://www.jpatterns.org

Our intention is a bit different to yours.  We want developers to start annotating their intentions, in order to make it easier for future developers to understand what they were trying to do.  However, we should probably
Regards

Heinz
-- 
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun Java Champion
http://www.javaspecialists.eu
Tel: +30 69 72 850 460
Skype: kabutz 
Reply all
Reply to author
Forward
0 new messages