DEV Community

Cover image for Code Smell 57 - Versioned Functions

Code Smell 57 - Versioned Functions

Maxi Contieri on January 20, 2021

sort, sortOld, sort20210117, workingSort, It is great to have them all. Just in case Problems Readability Maintainability S...
Collapse
 
yoursunny profile image
Junxiao Shi

What if:

  • It's a C function, where optional arguments are not supported.
  • A new version of the function adds an extra argument.
  • Old version cannot be deleted because it would break dependants.

The only way is to keep both old and new functions.

Real example: pipe and pipe2 in Linux syscall

Collapse
 
elmuerte profile image
Michiel Hendriks

That doesn't change the fact that it is a code smell. Sometimes language or runtime restrictions make code smells unavoidable.

Collapse
 
mcsee profile image
Maxi Contieri

Many bad languages introduce unavoidable code smells

We should be aware of them