Adding to CompositePattern

2 views
Skip to first unread message

Marco Tedone

unread,
Aug 15, 2010, 1:11:31 PM8/15/10
to jpatterns
Hi, while looking at the @CompositePattern I reliased that it's
missing something: a @DefaultMethod annotation to put on default
methods defined in the "Component" participants. I suggest we add the
following:

@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.METHOD)
@Documented
public @interface DefaultMethod {
String comment() default "";
}

This way one would know which methods in the "Component" are provided
just because of the signature but don't actually do anything (options
are ignore, throw a UnsupportedOperationException, etc).

Marco

Dr Heinz M. Kabutz

unread,
Aug 16, 2010, 11:41:51 AM8/16/10
to jpat...@googlegroups.com
I would vote against this for now, as this is not in the standard GoF
pattern. Any other opinions on this suggestion from Marco?

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

Marco Tedone

unread,
Aug 16, 2010, 11:50:37 AM8/16/10
to jpat...@googlegroups.com
Heinz, standard operations are shown in the gof diagram and personally I'd find useful to possibility to tag them as such.
Regards,

Marco
--
You received this message because you are subscribed to the Google Groups "jpatterns" group.
To post to this group, send email to jpat...@googlegroups.com.
To unsubscribe from this group, send email to jpatterns+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jpatterns?hl=en.

Dr Heinz M. Kabutz

unread,
Aug 16, 2010, 11:56:24 AM8/16/10
to jpat...@googlegroups.com
Hi Marco,

you mean the way I did this for the Template Method Pattern?

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

Marco Tedone

unread,
Aug 16, 2010, 12:03:54 PM8/16/10
to jpat...@googlegroups.com
Yep, like the templatemethod annotation.

Marco Tedone

unread,
Aug 16, 2010, 12:06:33 PM8/16/10
to jpat...@googlegroups.com
Errrrmmn sorry I meant primitiveoperation :-)

Dr Heinz M. Kabutz

unread,
Aug 16, 2010, 1:05:18 PM8/16/10
to jpat...@googlegroups.com
Compare the two diagrams though:

Composite:

http://www.jpatterns.org/apidocs/org/jpatterns/gof/CompositePattern.html

Template Method:

http://www.jpatterns.org/apidocs/org/jpatterns/gof/TemplateMethodPattern.html

(by the way, I just noticed that my naming was wrong. It should've been
PrimitiveOperation, not PrimitiveMethod.)

What would you like to make defaultMethod()? add/remove/getChild()? or
the operation()?

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

Marco Tedone

unread,
Aug 16, 2010, 2:09:03 PM8/16/10
to jpat...@googlegroups.com
add/remove/getChild() - Or, applying to the Composite exercise for the
webinar, isLeaf() and children(), so to speak.

Marco

Reply all
Reply to author
Forward
0 new messages