Design Patterns are typically encoded into Java code in an ad-hoc fashion. They are either embedded into the names of the classes or written into the Javadocs. Unfortunately it is impossible to accurately determine a pattern based solely on the class structure without knowing the intent of the code author.
JPatterns is a collection of annotations that make it easy to communicate the use of (Design)Patterns within your code to your fellow developers and your future self. We follow the KISS principle by using reasonable defaults for the annotation attributes. Thus, if you are writing a composite, you can simply specify:
@CompositePattern
public abstract class Contact {
public abstract void sendMail(String msg);
public void add(Contact contact) {}
public void remove(Contact contact) {}
}
Or, if you wanted to, you could also be more explicit, for example
@CompositePattern(role = CompositeRole.COMPONENT,
participants = {DistributionList.class, Person.class})
public abstract class Contact {
public abstract void sendMail(String msg);
public void add(Contact contact) {}
public void remove(Contact contact) {}
}
Please let us know if you would like to be part of this project by leaving a comment on this website.
Please access the repository here: http://github.com/jexp/jpatterns
Michael Hunger
Heinz Kabutz