Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB Convention

 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic