DEV Community

Discussion on: Should code have an expiry date?

Collapse
 
pedromsantos profile image
Pedro Moreira Santos • Edited

I like your idea, just not sure how to define n.

Thank you for your contribution to the discussion.

Collapse
 
lexlohr profile image
Alex Lohr

It depends on your requirements. A good starting value would be 5 changes to a function of normal cyclomatic complexity (5); whereas a higher complexity should allow for less changes before refactoring.

In this case, n = (5 changes * 5 average complexity) / cyclomatic complexity of function/file.

If you find out that you want to be more averse to higher complexity, you could also square the complexity: n = (5 changes * (5 average complexity)² / (cyclomatic complexity of function/file)².

Thread Thread
 
pedromsantos profile image
Pedro Moreira Santos

Very cool, don't leave this in a comment, I encourage you to post about this if you haven't already.