| Author |
JAXB Convention
|
Luke Murphy
Ranch Hand
Joined: May 12, 2010
Posts: 299
|
|
|
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: 16483
|
|
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: 299
|
|
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: 16483
|
|
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: 299
|
|
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.
|
 |
 |
|
|
subject: JAXB Convention
|
|
|