Sunday, 22 November 2009

Naming convention rant (no. 2)

I know it comes down to personal preference when it comes down to naming and I know it has been ingrained into me due to the people I have worked with over the past few years, but why do some people continue to do such things in this day and age.

Enums

Everyone who codes should know what an enum is, if they don’t then they either don’t code much or never use much if any of any frameworks which are out there. Either way then they should be looked and used; they are good!

Anyway, when someone writes their own enum to use instead of special strings or numbers then why prefix the enum with the string ‘enum’.  It’s not a enumOrientation it’s Orientation! etc. etc.

Class Names

I know this comes back to my rant the other week about the use of namespaces, however I came across another example with class names in another project which all the names of the classes where prefixed with the name of the last part of the namespace they where in.

So for example it was for a twitter app, and the namespace was <blah>.Twitter, and one of the classes was called TwitterRequest. I know this doesn’t sound bad in itself, but the fully qualified name of it would be <blah>.Twitter.TwitterRequest. This shows the issue I’m trying to portray. If its a Twitter request, then it should be in the twitter namespace and called Request. If it’s not a request to do with Twitter then it shouldn’t be in that namespace. Hope I’m making sense.

I just don’t understand why someone would do this? I think I might just be turning into a naming obsessive :-)

If you can’t think of a good name for one of your new classes then why don’t you try the class namer :-)

No comments: