Use of “the” prefix in object naming

namingnaming-standards

I am refactoring a large code base, and noticing the author often uses "my" to prefix object names. For instance, using myThingy to identify an object of type Thingy. Is this generally considered a good or bad naming pattern?

After listening to Software Engineering Radio's episode on naming, I am suspect to naming patterns and curious if there is a general consensus on this matter.

Best Answer

Sounds like the author has been cutting and pasting code examples, which commonly show classes that begin with My in order to illustrate that they are written by the individual (as opposed to framework classes or classes that are autogenerated). You're supposed to take off the prefix and/or name the class something that is relevant in the subject matter domain. Keeping the prefix is not a known convention I've ever heard of, and in fact is very pedestrian.

Also, class names should be capitalized in both Java and C#, so at the very least it should be MyThingy instead of myThingy.

Related Topic