I'm looking a name for a class in the system which has Id (Long) and Name (String) in a java environment.
Are their any conventions for this kind of class, or is it just architecture related?
I've seen some places where names such as IdAndName
have been used. I don't like it. Such names are too coupled with the current status of the class. It is quite likely that new feeds will be added to/removed from this class and then the name will stop being accurate.
So, I would encourage you to think along both of these directions:
What is this class representing? If this is the superclass of all "things" that have an "ID" and a "Name" then you can call it NamedEntity
(the term Entity
is quite common for describing persistent objects that maintain a distinct identity).
(Alternatively) do you really want to make it a superclass that many other classes extend? Sounds as if you can move to a design were your entities will hold such an object in a field (as opposed to inheriting from its class). You can then introduce a Nameable
interface which will define a getId()
and getName()
and have these entities implement these methods (cost in term of volume of code is marginal). This will give you better separation of concerns, less coupling (inheritance is the strongest form of coupling) and will not exploit the extends
card which you can play only once.