Posted by editor
on April 27, 2010 at 5:41 AM PDT
We've just published Michael Bar-Sinai's new article, "The Match Maker Design Pattern - a New Place for the Actions". In this article, Michael tackles some of the problems associated with object-oriented design within the context of the changing requirements that the real-life business world imposes on software applications over time...
We've just published Michael Bar-Sinai's new article, The Match Maker Design Pattern - a New Place for the Actions . In this article, Michael tackles some of the problems associated with object-oriented design within the context of the changing requirements that the real-life business world imposes on software applications over time. To see what I mean, here's Michael's opening paragraph:
Software systems often deal with similar concepts, whose behavior differs only slightly. Classic Object-Oriented design deals with such cases using inheritance; overriding the
calculateSalary() method in different
Employee subclasses allows the rest of the application to remain oblivious to the subtle differences between the salary algorithms of
In the article, Michael presents a solution that, while not a "silver bullet", provides benefits that work in a majority of real-life cases where you're updating software applications to address changed business requirements. His section "Dealing With New Classes On The Fly" opens with:
MatchMaker instance does hold a
Map mapping classes to handlers, but with a twist. When it is given an instance of a class for which a handler was not explicitly specified, it embarks on a breadth-first search (BFS) up the class hierarchy, starting from that object's class, looking for a class for which a handler was explicitly specified. A property of BFS is that it ensures that the class found is the closest one to the original object's class. Note that there might be a few classes with the same distance.
Figure 1. Class hierarchy and handlers example.
The article contains plenty of code snippets that illustrate the match maker technique. Michael concludes the article with this summary:
We have seen the Match Maker pattern, which allows programmers to:
- add actions on objects without modifying the objects those actions operate on;
- add objects and have appropriate actions automatically operate on them; and
- work on a subclass while holding only a superclass reference to it, without downcasting.
We have seen two implementations, one simple yet not statically type safe, and one effectively type safe. Creating a full statically type safe solution is left as an exercise to the reader, providing the reader is looking for a subject for a PhD thesis.
I have used this this pattern in production code for analyzing emails, drawing tables, building UI, and handling JMS messages; I hope you'll find it useful too.
As you can see, not only is The Match Maker Design Pattern - a New Place for the Actions interesting and informative, it's also fun to read!
In Java Today , Frank Kieviet, departing manager of the OpenESB project, presents Working with java.net: tips and tricks for project owners :
In the past two years I've managed the OpenESB open source project. This project is hosted on java.net. In this post I outline a number of tips and tricks I've learned while managing this project on java.net. This is useful information for my successor, but it also may be useful to other people who are managing projects on java.net. Web presence: An important factor in the success of an open source project is its web presence: it will be the first point of contact between a potential new user and the project. New visitors will want to see answers to these four items immediately...
presents Fundamo, OSGi, iPad.. and More GlassFish News - April 24rd, 2010
Financial services on the go - GlassFish for Fundamo and profit: Alexis recently published a new Adoption Story on how Fundamo uses GlassFish v2 and OpenMQ for its Enterprise Platform . Overview at stories entry , details in questionnaire , and an overview in this earlier short video interview . We are always interested in more GlassFish adoption stories, both from (non-paying) users and from (paying) customers. Stories come from all industries and around the world, the last few entries are PSA Peugeot Citro