-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: pros and cons of using interfaces on DTO classes
PostPosted: Wed May 24, 2006 3:39 am 
I haven't found any documentation for this on this website nor on the web or in the literature so I am wondering what the advantages and disadvantages are of using interfaces for my DTOs instead of POJOs.

I have only used POJOs so far and I can see that programming against interfaces allows me to mock the DTOs.

Other than that though are there any other advantages, or are there any pitfalls?

Thanks


Top
  
 
 Post subject: my 2c
PostPosted: Wed May 24, 2006 11:55 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
If DTO means Data Transfer Objects then I suggest you to stick with POJOs
http://java.sun.com/blueprints/corej2ee ... bject.html

Or do you mean Domain Test Object?
http://www.autotestguy.com/archives/200 ... rns_2.html

Or something else? ;)

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 4:23 pm 
I acknowledge your questioning of my language. Both of those patterns you reference are ones that I am partly using, although I am not using EJBs.

The term that I should have used instead of DTO is "persistent class or object" which is the language hibernate uses in its documentation.

You suggest I stick with POJOs - I assume you mean without interfaces. May I ask why?


Top
  
 
 Post subject:
PostPosted: Wed May 24, 2006 4:57 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Because:
- mapping interfaces and not objects is a bit tricky in Hibernate and I have impression that Hibernate has many bugs yet to be discovered in the space;
See for example: http://opensource.atlassian.com/project ... e/HHH-1189
- even without using interfaces Hibernate weaved object might be tricky to use, for example if you have object MyA that has a list of Bs and you want to serialize it and sent it across the wires you might be surprised that you need hibernate.jar on client. That is because when the object gets loaded form DB then Hibernate uses own implementation of List interface. To get rid of the effect you may need to create a true DTO as in Data Transfer Object pattern or VO;
- I also big fun of simplicity and POJO is the simplest thing that works :) I recommend using interfaces sparingly and only when you need them. Introducing them later when and if needed is VERY simple with IDE like Intellij-IDEA, if yours does not allow it I recommend changing IDE ;)

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 5:15 pm 
Interesting point if somewhat contentious suggesting there are 'many' bugs awaiting discovery.

I am still hoping for some more obvious pros and cons on the subject, if there are any.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.