views:

14

answers:

1

I am working on a UI where the top level, logical grouping of display objects is 2-D or 3-D (variety of objects can be displayed either two dimensionally or three dimensionally.)

My language of choice does not allow for numeric characters to be the first character of an identifier (not actually aware of any that do) so I'm looking for a sane and legible prefix to use. I have thought of:

  • Ddd (e.g. DddObject or DdObject)
  • ThreeD (e.g. ThreeDObject or TwoDObject)

But both options look ugly and weird to me. Has anyone come up with a cleverer replacement to 2-D and 3-D object naming?

+1  A: 

I have used 'TD' once (for 3D), but that's not very intuitive. I think you should use a 3D or 2D suffix where required, as suggested by SigTerm above, for example Point2D and Point3D. In other cases, like TriMesh, where it is obvious that the object is 3D, there is no need for either a prefix or a suffix.

I have personally found it best to avoid prefixes and suffixes as far as possible. Not only does this save you some typing effort, but the code also becomes more readable. Of course, the convention will also depend on the context. For example, if you have a scene object that can hold both 2D and 3D object, you would like to name it just 'Scene'. However, your problem might dictate having two separate structures for the 2D and 3D scenes, in which case you might want to name them 'Scene2D' and 'Scene3D'.

Using something more abstract is not good in the long term, because there is just no way that you can fully convey the logic behind the choice to others, and over time it will become more and more open to misinterpretation. For example, someone, someday might end up adding a class called Loggin3D, for log errors :)

tathagata