DEV Community

Cover image for Code Smell 38 - Abstract Names
Maxi Contieri
Maxi Contieri

Posted on • Edited on • Originally published at maximilianocontieri.com

1

Code Smell 38 - Abstract Names

Avoid too abstract names. Names should have real world meaning

Problems

  • Implemental Naming

  • Meaningless names

  • Broken MAPPER and Bijection to real world entities.

Solutions

  1. Choose meaningful names.

  2. Find metaphors.

  3. Avoid words like abstract, base, generic, helper etc.

  4. Use rules for naming.

Sample Code

Wrong

<?
final class MeetingsCollection {}
final class AccountsComposite {}
final class NotesArray {}
final class LogCollector {}
abstract class AbstractTransportation {}

Right

<?
final class Schedule {}
final class Portfolio {}
final class NoteBook {}
final class Journal {}
final class Vehicle {}
view raw realNames.php hosted with ❤ by GitHub

Detection

We can set up policies and rules warning for certain words like base, abstract, helper, manager, object etc.

Tags

  • Naming

Conclusion

Finding names is the last thing we should do on our designs. Unless we have a clear business understanding, good names emerge at the end after defined behavior and protocol boundaries.

Relations

More info

what is in a name

Credits

Photo by Rodion Kutsaev on Unsplash


There are only two hard things in Computer Science: cache invalidation and naming things.

Phil Karlton

Postmark Image

Speedy emails, satisfied customers

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

Sign up

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more