While reading through the DynaActionForm debate, I wondered if using Interfaces as well as inheritance might be a good alternative for those who want type enforcement but don't want to duplicate common form elements. I inherited a fairly large struts application months ago with 30+ forms. However, I have recently realized that none of the forms use inheritance at all to share common attributes even though there are glaring examples of forms just waiting to be combined: ie:
PrintDocumentForm PrintMultiPageDocumentForm PrintWorkflowDocumentForm The three forms share 90% of the same attributes, but no one took the time to create a superclass. In addition to the benefit of checking data typing, I like having superclasses for common forms because it ensures that I am going to call the same property the same name on multiple forms. One of the major headaches of this project is that there are many forms that refer to the same bean property but are named slightly differently (i.e., container_id, _container_id, containerId). While inheritance will take you most of the way in solving naming conflicts and type conflicts, I am trying to use interfaces to take me the rest of the way. In the form example above, I have created three interfaces: Document MultiPageDocument WorkflowDocument and four forms PrintForm PrintDocument extends PrintForm implements Document PrintMultiPageDocument extends PrintForm implements MultiPageDocument PrintWorkflowDocument extends PrintForm implements WorkflowDocument Every bean property on the three subclass forms are either inherited or implemented from an interface. This way I can avoid naming conflicts by only naming a property that is used across multiple forms only once. Has anyone else done something similar? Or is there a better solution to this problem that would use less code? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]