Dev Genius

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

Follow publication

Code Smell 96 — My Objects

Maximiliano Contieri
Dev Genius
Published in
1 min readOct 25, 2021

Photo by Michał Bożek on Unsplash

TL;DR: don’t use my as a name prefix.

Problems

  • Lack of context
  • Bijection Fault

Solutions

1. Remove “my” prefix.

2. Change to a role suggesting name.

Context

Several old tutorials use the word ‘my’ as a lazy name.
This is vague and lead to context mistakes.

Sample Code

Wrong

Right

Detection

[x] Automatic

We can tell our linters and static checkers to search for this prefix and warn us.

Tags

  • Naming

Conclusion

Avoid using my.

Objects change according to the usage context.

More Info

Thinking about my experience of modifying code, I see that I spend much more time reading the existing code than I do writing new code. If I want to make my code cheap, therefore, I should make it easy to read.

Kent Beck

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