Reviews : New Tricks With Design Pattern: Java Value Types :

Combining JVT with Other Patterns

We have shown above some advantages in using the JVT with the ServiceLocator pattern. When used with a Session Facade pattern, the value types can entirely hide the technology being used for data access or management. This means the user or web service interface can make logical requests on the Session Facade to exchange value types with the data access or management sub-systems. This can eliminate the dependence on a single data access technology such as CMP entity beans, JDO, etc. Projects can often migrate from one to another or use a combination of both methods where appropriate. The extra plumbing JVTs provide are excellent for managing stateful objects in a multi-threaded environment such as that of web services and/or web applications.

Value Types in a Team Environment

When used in a team environment the value objects and value types lend themselves to better enabling parallel efforts. One such method uses "mock" value types to enable complete development and testing of a web or rich client user interface prior to completion of the data access and EJB frameworks. These "mock" value types are the actual classes used by an application but with test values used to emulate those produced by or sent to the data access and/or EJB components. Another benefit utilizes the JUnit testing framework to fully test the EJB and value types without adding the complexity of the user interface classes.

The ability to make mock JVT's makes it really easy for different teams to work on different tiers at the same time. It also allows for parallel development of separate parts of the same tier (like different session facades for web services, jms, etc). The testing advantages are valuable in that you can not only use the mock JVT's as mock input for a module, but you can also have a mock JVT that the output of a module should match. If you implemented the JVT equals method properly, you can easily compare the actual output and the desired output. Mock JVT's also make prototyping easier. JVT's force the designer to make clear separations between modules and to clearly define what data will move between them. It forces the designer to also realize when they are changing the interface (in that they must have changed the JVT).

Summary

JVTs provide an efficient vehicle for transporting information to the technologies that act upon them. JVTs can be a very useful pattern in designing and developing flexible object models. The decoupling of technologies and the simplification of access between the design layers can make projects far more maintainable, testable and adaptable to new technologies. This design pattern is intended as a beefier set of value objects that can significantly streamline medium to complex J2EE projects. When combined with utility classes using reflection they can simplify object transport and access in everything from processing JMS messages to exporting XML representations of your objects.


About the Author

Noah Horton is an R&D Engineer at Hewlett-Packard. He has been programming in Java for five years and specializes in enterprise system design with Java.


How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.