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.
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 :)
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.
I've used My in 2 situations:
- Way back when in my first programming classes in school
- When I am doing basic 'hello world' applications to learn a language
but NEVER in production or even pseudo-production code.
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.
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.