Zen of Defensive Programming: Clear Intentions

As I pointed out in my previous post, making your intentions clear is crucial in defensive programming. You never want anyone to guess what your code does. Instead, without ambiguity, you want to make sure everyone understands what your code doing.

Here is another example of a coding practice that I see everywhere.

int newValue = value >> 3;

Most seasoned programmers probably know immediately what is being done here. A bit-shift to the right by 3 is the same as a division by 8. Only, it...

 •  0 comments  •  flag
Share on Twitter
Published on May 09, 2022 08:00
No comments have been added yet.