This is review of the 3rd chapter from the book-”Clean Code: A Handbook of Agile Software Craftsmanship” by Robert C. Martin
A class is nothing but a collection of functions. Functions are what your program is.
In this chapter- Functions are discussed-how they improve your code and how they can push you – I mean your program over the cliff.
Rules regarding responsibility, error handling, size of the functions, naming conventions, arguments,side affects ,repetition are discussed.
When we write code – we of course communicate with the processor – telling it what to do- but we also hold a dialogue with fellow programmers who will come in after you – as to what you are trying to achieve. Functions are integral to a good communication between you and others. Processor wouldn’t mind if you have named your function as doit() . But it does matter to your fellow programmers.
Function signature reveals intent of what you are doing and the body explains how you are doing. You should be able to take one quick glance at the signature and know what the function does.
A good function would be small in size, does one thing and one does it well, has a meaningful name, doesn’t mix error handling and core logic in one place, has 0-3 arguments, offers no surprise, no side affects.
For other chapters- please see this post.

Recent Comments