It kicked off a little bit on Twitter earlier today over readability and clean code following the article
Why Destructuring Is A Terrible Idea.
Essentially it comes down to semantics. What exactly is Clean Code? What is readable code? The most famous book on the subject is the one by Robert Martin, where he presents his views in no uncertain terms, for example:
Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very special justification – and then shouldn’t be used anyway.
While I certainly agree that fewer arguments are better, there is no scientific evidence used here to back up any claim that other developers cannot read and understand a function with three or four arguments in it.
In the book Code Complete, Steve McConnell references numerous studies throughout his book, and says that research has shown that more than SEVEN arguments is difficult to understand. So there is quite a big difference of opinion here.
Psychological research has found that people generally cannot keep track of more than about seven chunks of information at once (Miller 1956)
Many of the opinions on Clean Code apply very well to class based languages such as Java and C#, but for sophisticated applications written in JavaScript they aren’t always practical.
For example the Google Maps API – some functions here have dozens of arguments – someone needs to go and refactor this thing urgently!!!
Or do they? How many compromises would you need to make in order to satisfy the requirement that no function should have more than two arguments in it? What would it do to the performance?
Software Engineering is unfortunately too complex to have a one size fits all full definition of what constitutes readable code. There are a number of best practices well worth adopting, but at times we also need to be a little flexible and appreciate that we can only optimize for a few things and that other aspects of code quality often need to be compromised to some degree when finding the best trade-off.
Further Reading
Its life but not as we know it
Pingback: Clean Code: Writing Code for Humans | Zombie Code Kill