jQuery in Action, 2nd edition*
The moose likes XML and Related Technologies and the fly likes JAXB Convention Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB Convention" Watch "JAXB Convention" New topic
Author

JAXB Convention

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
I am thinking of introducing a convention in my project that any JAXB classes begin with the the letter 'X'. What you think?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I wouldn't use prefixes ever to identify any feature at all in Java identifiers. If you truly have a class which exists only because you're using JAXB, then I might call it CustomerJaxb or something like that. But if it's a class which happens to be produced by marshalling out of JAXB, I wouldn't mention that in its name at all.

Edit: I guess it would be a good idea to think up some technical reason why I said that. Well, because it isn't a good practice to embed implementation details into the name of a class, or variable for that matter.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Paul Clapham wrote:I wouldn't use prefixes ever to identify any feature at all in Java identifiers. If you truly have a class which exists only because you're using JAXB, then I might call it CustomerJaxb or something like that. But if it's a class which happens to be produced by marshalling out of JAXB, I wouldn't mention that in its name at all.

Edit: I guess it would be a good idea to think up some technical reason why I said that. Well, because it isn't a good practice to embed implementation details into the name of a class, or variable for that matter.


What about Swing? JPanel, JFrame? I thought it worked well there. It differentiated it from AWT. Similary say if you want to differentiate between JAXB style classes and JPA versions of the same classes?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Luke Murphy wrote:Similary you want to differentiate between JAXB style classes and JPA versions of the same classes?


Sure. But that wasn't the question you asked.

And from what I've seen, people tend to use suffixes rather than prefixes to do that sort of differentiation. Prefixes just make you wade through a big list of classes named "XThis" and "XThat" in the API docs (one of the things I disliked about Swing's habit of starting most of their class names with J) and then "PCustomer" and "XCustomer" are nowhere near each other in the docs.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Paul Clapham wrote:
Luke Murphy wrote:Similary you want to differentiate between JAXB style classes and JPA versions of the same classes?


Sure. But that wasn't the question you asked.


True. Usually that would be the case in a classical OLTP architecture. Sorry for making the assumption - that's generally whay I have worked on.
 
jQuery in Action, 2nd edition
 
subject: JAXB Convention
 
Similar Threads
Java API to parse an XML schema !
need help in JAXB
which jar file includes InterningXMLReader.class
object to XML
How do you parse an XML File?