« Java EE 5 Architektu... | Main | Interesting Resource... »
 20070906 Thursday September 06, 2007

Generic Data Transfer Object checked into p4j5

A sample implementation of the Generic Data Transfer Object pattern is checked in to p4j5. The idea of the GDTO is to provide a flexible, but type-unsafe, way to transport data between tiers.
Beyond pure data transport the GDTO can be also used for validation. The flexibility of the GDTO costs also performance - there are more instances involved.

It is also not very easy to work with GDTO directly:

  private GenericDTO generic;
 
    public void setUp(){
         this.generic = new GenericDTO("Cart");
    }
 
   public void testAdd() {
        assertEquals(0,this.generic.getNumberOfAttributes());
        StringType description = new StringType(null,"a simple cart for test purposes");
        this.generic.add("description", description);
        assertEquals(1,this.generic.getNumberOfAttributes());
        assertFalse(this.generic.isEmpty());
        String toString = generic.toString();
        assertNotNull(toString);
        System.out.println(toString);
    }

However it's intended to be used in reflective way (e.g. binding the UI automatically to the GDTO). Changes to the underlying data also do not affect the compatibility of the interfaces/layers - however the stability of the interface requires more testing. The lack or renaming of attributes can cause runtime exceptions.
Gesendet von admin [Java EE 5 Architectures] ( September 06, 2007 12:07 PM ) Permalink | Kommentare [0]
[my website] [This entry is based on / extends my books: Enterprise Architekturen, Leitfaden fuer effiziente Software-Entwicklung and: Java EE 5 Architekturen, Patterns und Idiome]

Kommentare:

Senden Sie einen Kommentar:

Name:
E-Mail:
URL:

Ihr Kommentar:

HTML Syntax: Ausgeschaltet



License
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.0 License.