DEV Community

Cover image for Code Smell 171 - Plural Classes
Maxi Contieri
Maxi Contieri

Posted on • Originally published at maximilianocontieri.com

8

Code Smell 171 - Plural Classes

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.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
yoursunny profile image
Junxiao Shi

What's a better name for EcdsaParams?
developer.mozilla.org/en-US/docs/W...

Collapse
 
mcsee profile image
Maxi Contieri

Params is an abreviattion, so it is another code smell

blog.devgenius.io/code-smell-33-ab...

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay