# Code Smell 57 - Versioned Functions

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

# 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

[Gist Url]: # (https://gist.github.com/mcsee/3b63bc3a76faf6e98c3770171f8e1c10)
```javascript
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

[Gist Url]: # (https://gist.github.com/mcsee/1e3df98869010c8b9f37f1a76ff80c8b)
```javascript
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

%[https://maximilianocontieri.com/code-smell-05-comment-abusers]
 
# Credits

<span>Photo by <a href="https://unsplash.com/@k8_iv">K8</a> on <a href="https://unsplash.com/s/photos/onion">Unsplash</a></span>

Original idea

%[https://twitter.com/svpino/status/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_

%[https://maximilianocontieri.com/software-engineering-great-quotes]

* * *

This article is part of the CodeSmell Series.

%[https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code]
