method names nounVerb or verbNoun

Martin P. Hellwig martin.hellwig at dcuktec.org
Thu Feb 11 11:23:34 EST 2010


On 02/05/10 19:53, Wanderer wrote:
> Which is the more accepted way to compose method names nounVerb or
> verbNoun?
>
> For example voltageGet or getVoltage? getVoltage sounds more normal,
> but voltageGet is more like voltage.Get. I seem to mix them and I
> should probably pick one way and stick with it.
>
> Thanks

For me personally I do the following:
spam_get/spam_set; might be preferred if you have more spam_* functions 
(i.e. spam_del, spam_eat, etc.)

set_spam/get_spam; is I think reasonable if you have also a *_ham 
function (i.e. set_ham, get_ham).

Funny thing for me is that when I have both spam_* & *_ham naming, I 
usually rethink my approach and split it out to separate classes/modules.

Please note that this is at the moment a personal, uneducated, never 
really thought about it, preference. Meaning it is very likely that with 
some more insight there is a good chance that I find my approach in 
retrospect flawed.

-- 
mph



More information about the Python-list mailing list