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.

AWS Q Developer image

Build your favorite retro game with Amazon Q Developer CLI in the Challenge & win a T-shirt!

Feeling nostalgic? Build Games Challenge is your chance to recreate your favorite retro arcade style game using Amazon Q Developer’s agentic coding experience in the command line interface, Q Developer CLI.

Participate Now

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...

Build gen AI apps that run anywhere with MongoDB Atlas

Build gen AI apps that run anywhere with MongoDB Atlas

MongoDB Atlas bundles vector search and a flexible document model so developers can build, scale, and run gen AI apps without juggling multiple databases. From LLM to semantic search, Atlas streamlines AI architecture. Start free today.

Start Free

👋 Kindness is contagious

Discover fresh viewpoints in this insightful post, supported by our vibrant DEV Community. Every developer’s experience matters—add your thoughts and help us grow together.

A simple “thank you” can uplift the author and spark new discussions—leave yours below!

On DEV, knowledge-sharing connects us and drives innovation. Found this useful? A quick note of appreciation makes a real impact.

Okay