DEV Community

Discussion on: Stop Using "data" as a Variable Name

Collapse
 
vlasales profile image
Vlastimil Pospichal

The words get, find, fetch, add, update, delete are not a prefix for me, but a name for methods. For classes that have 2-5 methods, this is completely satisfactory, I do not make longer classes. If one word is not enough, it means that the class violates the SRP.

Collapse
 
dcwither profile image
Devin Witherspoon

Yes, I should have pointed out the context of that particular rule. It’s been a long time since I’ve worked with OOP, but you’re definitely right that these can be full method names for well named, well purposed classes.

Collapse
 
vlasales profile image
Vlastimil Pospichal

It was a long and difficult journey before I came to this knowledge. Unfortunately, many developers in OOP do not share this idea.

However, I do not have it as a dogma, but rather as a guide to clean code.

The next level is class names and namespaces. I prefer to combine a maximum of two words in classes, one word for one namespace element. I avoid the general words domain, manager, controller, infrastructure, etc.