| |  |
Home In This Issue Email a Friend EasyPrint
 | |
|
Using a reusable code approach to HTML select option lists, part VI (continued)
The basic pattern is almost always the same Generally speaking, when you select some function to make reusable, you usually end up with a very similar set of elements in the resulting framework. Those elements include:
- The Java Interface defining the desired behavior;
- An abstract class that implements the Interface and provides common code;
- One or more specialized abstract classes that extend the base code and provide code common to a particular category of implementing classes;
- Any number of implementing classes that either extend the base code directly or extend one of the specialized abstract classes;
- External configuration parameters to select and configure your implementing classes;
- Some type of component factory to configure components based on the configuration.
I chose the OptionListSource as my example, but I could have just as easily chosen to use something else, such as formatting a menu for inclusion on a rendered page. Instead of creating SimpleOptionListSource objects and SqlOptionListSource objects we would have been dealing with VerticalNavigationFormatter objects and PullDownHorizontalNavigationFormatter objects and DirectoryTreeNavigationFormatter objects. Whether you're dealing with something as simple as a list of valid values or as complex as an enterprise application event management subsystem, the process is virtually the same: define the standard behavior in an interface, implement as much of the common logic as you can in an abstract class of base code, and then extend that base to create specialized abstract classes and/or final implementing classes.
By applying this pattern consistently, you'll begin to amass a portfolio of reusable components from which you can mix and match various elements to assemble applications rather than writing all of the code from scratch every time.
Summary Well, that's about it! For those of you that found the actual code useful, I have compiled a .jar file containing all of the examples that we have used in this series. You're welcome to take them and do with them as you see fit. In fact, I would be interested in seeing any extensions or enhancements that anyone might come up with. But again, I hope that you took away more from this little series than just the code examples, because from my perspective at least, the real benefit lies in the ideas behind the code more than it does the software itself. Either way, I hope you enjoyed this little adventure as much as I did, and if you made it this far, thanks for hanging in there with me!
Jeff Chilton is Vice President of Fulfillment at Echo Technology Group, Inc., an IT consulting firm that specializes in enterprise-focused best practices. He can be reached at jchilton@teametg.com
[ Prev ]
|
|
-- Advertisement --
SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:
- Fully validated
- Up to 256-bit encryption
- One, two, or three year validity (our Turbo SSL Certificates are valid up to 10 years)
- 99% browser recognition
- Stringent authentication
- Around-the-clock customer support
Build trust. Protect your customers. Grow your online business.
Tap here now and be IronClad with SSL tonight. |
|
Copyright © 2008, ZATZ Publishing. All rights reserved worldwide.
|