This week in the JavaWorld developer forums

Opinion
Nov 15, 20072 mins

Week of November 11, 2007

Java Programming Theory and Practice:

Forum Veteran Jeroen writes:

“I’m working on the design of an application that can be used to build a ‘workflow’ for a given type of document. The workflow consists of actions that are applied to the document, such as performing an XSLT transformation, writing the document to a file etcetera. Each of these actions is implemented by an Action. I’ve defined an AbstractAction superclass that implements the common functionality for all Actions, such as parameter validation. Some parameters are mandatory, others are optional. I would like to have the AbstractAction class to perform the check for the presence of all mandatory parameters.

Of course the AbstractAction class is not aware of which parameters are mandatory for a certain subclass. I would like to maintain the list of mandatory parameters in each subclass. The question is: how to implement this? Some kind of data structure must be shared by the AbstractAction and its subclasses. The check should be ‘automatic,’ meaning it should not require an additional method call from the AbstractAction to the subclass.”

Can you help? Or maybe you’d just like to learn:

How to populate a data structure from a subclass

More Q&A in the JavaWorld Developer Forums:

A question about threads …

Encryption with Bouncy Castle

Converting a generic list to an array

Need help overriding a method — I’ve tried everything!

Want more?

The JavaWorld Developer Forums: Solutions for Java developers