Is there a better way to handle naming quirks?

Last year and a bit of work on my team code base, I noticed a steady development of naming conventions.

For example, there are many classes for which it is indicated that they are a class that helps you do something.

Here are the ones I noticed:

MyClassUtil
MyClassFactory
MyClassHelper
MyClassManager
MyClassService

It seems to me that over time, people come up with naming conventions for relatively the same thing, and therefore, instead of everything being called sequentially, you end up with a code base that has a bit of each convention. All new materials are named based on the latest fad naming convention, and so you can pretty much talk about the age of the code, which was then in fashion.

What is the best way to deal with this trend? Is this really a problem? How do these lures come into fashion, should you use the latest quirk? Should all existing elements be renamed with a new naming convention? Or do you just have to accept diversity as something that is inevitable?

+3
source share
7 answers

They do not seem quirks ... all these names allude to the goal of the class, and these goals are different. With programming, all this is in the name, and they should be chosen very carefully. The variety should not be avoided. Names are different because the goals of these classes are different.

MyClassUtil - MyClass, . , MyClass , , , - .

MyClassFactory - MyClass . , MyClass. MyClassFactory. Factory , MyClass. , Factory /mock MyClasses. , , Factory, , factory voilà, .

MyClassHelper -, , , . - MyClass, . , MyClassUtil. , , MyClassUtil - , MyClass, MyClass, . MyClass .

MyClassManager - MyClass . . CommunicationManager , , ethernet serial, , comms, , , .

MyClassService - - , , , . . , - .

+5

, , - . , "MyClassUtil" "MyClassService". . . . - - .

, , , , "MyClass" - , 't , , .

+4

, OO: OO, , Evans "Domain Driven Design".

"Util" "Manager" - " ". "" ( Rails), .

"Factory" "Service" , , , .

, , , , , , , .

. , . , . , , , .

+4

, . , , .

, . , "", , , , . , , , .

+2

, Factory Service ...

Factory , Factory, .

Windows, ?

, , , .

0

, ?

.NET, Microsoft StyleCop

0

In the class examples that you specify, "MyClass" represents the actual name of the class, so do you really see names like "PersonnelRecordUtil" or "GraphNodeFactory"? MyClassFactory is a really bad actual name for the class.

0
source

Source: https://habr.com/ru/post/1702895/


All Articles