DEV Community

Discussion on: In Defense of Clean Code: 100+ pieces of timeless advice from Uncle Bob

Collapse
 
pinotattari profile image
Riccardo Bernardini

This reminded a lot of the Ada style guide (yes, it is a thing!)

About functions

  1. Functions should be pure, meaning that they don’t have side effects and don’t modify their input arguments.

Yes, in theory, but there are many cases where a function with side effects makes the code smoother and clearer. The typical example is a lexical analyzer function that returns the current token and move to the next one. Yes, you can replace it with a procedure, but having a function is much more convenient, so

Embrace pragmatism, not dogmas.

Collapse
 
thawkin3 profile image
Tyler Hawkins

Absolutely. Being pragmatic about these guidelines is the key. Not every rule applies in every situation, and wisdom is knowing how to apply these ideas appropriately.