views:

132

answers:

6

Personally, I've never liked the MyObject naming of classes. I would guess that the status quo would agree but I'd like to see the other side of the argument and if there's any validity to it.

+6  A: 

'My' is already used by me, use something else

Remus Rusanu
Exactly what I was going to say (but Remus said it better). Unless you're always doing 1-man projects that will never be maintained by anyone else, "My" just isn't very descriptive :-)
Eric J.
+4  A: 

I've never seen it done in production code, although I dare say it exists.

It's like the metasyntactic variables "foo" and "bar" - it's usually used as a placeholder for a real name.

So for example, if I know that someone has their own class deriving from Form, but I don't know anything else about it, a code example would use:

public class MyForm : Form

I'd certainly take a firm stance against it for real code though :)

Jon Skeet
+3  A: 

I suppose one instance where it would be close to acceptable is if the class you're prefixing with "My" is an inner class (i.e a private class declared within another class). I'm not sure if there are any naming conventions governing inner classes, but this could be one way to differentiate.

Pwninstein
Interesting... Isolated from the rest of the code and the "My" makes sense with respect to the class. +1
Austin Salonen
A: 

I've used My in 2 situations:

  1. Way back when in my first programming classes in school
  2. When I am doing basic 'hello world' applications to learn a language

but NEVER in production or even pseudo-production code.

Badfish
A: 

I'd avoid it in production code, your type name should reflect the function its supposed to perform.

I've used it a couple of times when patching/hacking third party code, for instance replacing Controller with MyController to make it clear it is a hack, that should be approached with caution, and a bat.

Rich Seller
A: 

As far as I've ever seen, My is a prefix used in sample code that indicates "your stuff goes here".

It's kind of like foo. Teaching purposes only.

Ken