cover-img

Code Smell 57 - Versioned Functions

sort, sortOld, sort20210117, workingSort, It is great to have them all. Just in case

28 March, 2023

3

3

0

Problems

  • Readability
  • Maintainability

Solutions

  1. Keep just one working version of your artifact (class, method, attribute).
  2. Leave time control to your version control system.

Sample Code

Wrong

findMatch()
findMatch_new()
findMatch_newer()
findMatch_newest()
findMatch_version2()
findMatch_old()
findMatch_working()
findMatch_for_real()
findMatch_20200229()
findMatch_thisoneisnewer()
findMatch_themostnewestone()
findMatch_thisisit()
findMatch_thisisit_for_real()

Right

findMatch()

Detection

We can add automatic rules to find versioned methods with patterns.

Like many other patterns we might create an internal policy and communicate.

Tags

  • Versioning

Conclusion

Time and code evolution management is always present in software development. Luckily nowadays we have mature tools to address this problem.

Relations

Code Smell 05 - Comment Abusers

Creditshttps://pbs.twimg.com/media/FWcrogWWQAAXXb1?format=png&name=small

Photo by K8 on Unsplash

Original idea

https://twitter.com/1341808635115151360


That's why I write, because life never works except in retrospect. You can't control life, at least you can control your version.

Chuck Palahniuk

Software Engineering Great Quotes


This article is part of the CodeSmell Series.

How to Find the Stinky Parts of your Code


3

3

0

Maxi Contieri

Buenos Aires, Argentina

🎓Learn something new every day.📆 💻CS software engineer 👷coding👨🏽‍🏫teaching ✍🏾writing 🎨Software Design 🏢SOLID 🌉TDD 👴Legacy 💩Code Smells

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.