Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are some class names that would signal a need for refactoring?
    primarykey
    data
    text
    <p>I came across a few articles like <a href="http://www.bright-green.com/blog/2003_02_25/naming_java_classes_without_a.html" rel="nofollow noreferrer">this one</a>, which suggest that some words should never be used as part of a class name. When a class has one of those words in the name, it means the code should be refactored or redesigned.</p> <p>Example:</p> <p><strong>Manager</strong></p> <p>Reason: Since almost all classes "manage" something and the meaning of "Manager" is very broad, people can put a lot of responsibilities to a "Manager" class while still being able to claim the class does "only one thing". As a result, naming a class with "Manager" does not say much about what the class actually does. The article mentioned earlier, <a href="http://www.bright-green.com/blog/2003_02_25/naming_java_classes_without_a.html" rel="nofollow noreferrer">"Naming Java Classes Without a 'Manager' "</a>, showed this point:</p> <blockquote> <p>For instance, take a class named "UrlManager" - you cannot tell whether it pool URLs, manipulates URLs or audits the use of them. All the name tells you is that this is not a URL, but it does somehow work with them. On the other hand, the name "UrlBuilder" gives a much better picture of what the class does.</p> </blockquote> <p>Another example:</p> <p><strong>Helper</strong></p> <p>Reason: A class name like "ThreadHelper" makes people wonder why it's needed and why it cannot just be part of the "Thread" class. Is it actually an adapter or a decorator? If so, name it that way. Is class "Thread" taking too much responsibility already? If so, refactor and give the new class a meaningful name. "Helper" says nothing about what it's doing or how it's helping.</p> <p>What are other words in a class name that would signal a need for refactoring or redesign and should be avoided? Why?</p> <p>Edit: I would think those words are used a lot since</p> <ul> <li>they generally have broad meanings</li> <li>they can fit in almost all contexts</li> <li>they stop designers thinking about better designs or names</li> <li>people believe it's OK to use them</li> </ul> <p>The book <em><a href="http://rads.stackoverflow.com/amzn/click/0132350882" rel="nofollow noreferrer">Clean Code</a></em> listed more but no reasons were given:</p> <blockquote> <p>Avoid words like Manager, Processor, Data, or Info in the name of a class.</p> </blockquote> <p>It would be great if someone could provide possible reasons for them.</p> <blockquote> <p>Related questions:</p> <p><a href="https://stackoverflow.com/questions/38019/whats-the-best-approach-to-naming-classes">What’s the best approach to naming classes?</a></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload