Code Smell 171 - Plural Classes

Maxi Contieri - Oct 21 '22 - - Dev Community

Classes are my precious

TL;DR: Classes represent concepts. And concepts are singular.

Problems

  • Naming

  • Code Standards

Solutions

  1. Rename classes to singular

Context

Naming things is hard.

We need to agree on certain rules.

Sample Code

Wrong

class Users
Enter fullscreen mode Exit fullscreen mode

Right

class User
Enter fullscreen mode Exit fullscreen mode

Detection

[X] Automatic

This is a syntactic rule.

Tags

  • Naming

Conclusion

Name concepts in the singular.

Classes are concepts.

More Info

Disclaimer

Code Smells are just my opinion.

Credits

Photo by Anton Malanin on Unsplash


We are still in the infancy of naming what is really happening on software development projects.

Alistair Cockburn


This article is part of the CodeSmell Series.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player