http://c2.com/cgi/wiki?DontCreateVerbClasses
Is using verbs considered bad practice?
What do you use, nouns or verbs? And why?
http://c2.com/cgi/wiki?DontCreateVerbClasses
Is using verbs considered bad practice?
What do you use, nouns or verbs? And why?
Hi…
Check out the books by Rebecca Wirfs-Brock.
yours, Marcus
As long as it makes sense to apply names like that, sure.
Now that I look back on some classes I built, I’ve used both nouns and verbs, but it depends on whether the class is primarily a data structure class (something that stores a collection of data), or an action class (a class that processes something). It that case, it looks like I tended to apply nouns for data structure classes, and verbs for action classes.
To clear up some confusion made by me. The example above with reader, listener and finder was supposed to just be a part of the class name. Therefor UserFinder and FileReader could be appropriate names.
Lastcraft: You mention “role based naming”, do you have any articles on that subject on hand? Thanks in advance. Can`t seem to find what I want through google.
There isn`t any material online that I can read in the meantime?
I`ve tried searching, but no luck.
That`s sounds reasonable for functions, but I was more thinking about class names. Is using reader, listener, finder etc. okey for names?
It depends. Use whatever naming convention you find useful and describes the function enough to know what it is, then keep the naming convention reasonably consistent.
combineText($text1, $text2){
return $text1 + " " + $text2);
}
Thanks for the tip
Hi…
Opinions will differ even at the top levels on this one. Most OO devs recommend role based naming for classes/interfaces. They tend to end in “er”. The problem with Manager and Listener is that they are too general purpose. SocketListener would be OK (something observing a socket).
yours, Marcus