Opinions on how to use My as a class name prefix

Personally, I never liked the assignment of the MyObject classes . I would assume the status quo would agree, but I would like to see the other side of the argument and if there is any validity.

+2


source to share


6 answers


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

It is similar to the "foo" and "bar" metasyntatic variables — usually used as a placeholder for the real name.

So, for example, if I know that someone has their own class derived from Form

, but I don't know anything about it, the example code would use:



public class MyForm : Form

      

I would of course stick to this rule for real code :)

+4


source


"Mine" is already used by me, use something else



+10


source


I am assuming that one instance where it would be close to valid is the class you prefix "Mine" is an inner class (ie a private class declared in another class). I'm not sure if there are any naming conventions that govern the inner classes, but this might be one way to tell the difference.

+3


source


As far as I've ever seen, My

this is the prefix used in the example code to indicate "your stuff goes here."

It's kind of like foo

. For educational purposes only.

+1


source


I have used My in two situations:

  • Back when in my first programming classes at school
  • When I do basic hello world applications to learn a language

but NEVER in production or even pseudo production code.

0


source


I would avoid this in production code, your type name should reflect the function it should perform.

I've used it a couple of times when fixing / cracking third party code, for example replacing with Controller

to MyController

make it clear that this is a hack that should be treated with care and bat.

0


source







All Articles