Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Follow publication

Code Smell 65 — Variables Named After Types

Maximiliano Contieri
Dev Genius
Published in
2 min readApr 2, 2021

Photo by Sangga Rima Roman Selia on Unsplash

Problems

  • Declarative
  • Design for Change
  • Coupling to accidental implementation

Solutions

1. Rename your variable according to the role.

Sample Code

Wrong

Right

Detection

This is a semantic rule. We can instruct our linters to warn us from using names related to existing classes, types o reserved words since they are too implementative.

Tags

  • Declarative

Conclusion

The first name we can across is related to an accidental point of view. It takes time to build a theory on the models we are building using our MAPPERS. Once we get there, we must rename our variables-

Relations

More info

Credits

This idea came from this tweet

Types are essentially assertions about a program. And I think it’s valuable to have things be as absolutely simple as possible, including not even saying what the types are.

Dan Ingalls

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Written by Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

No responses yet

Write a response