Some insightful thoughts
- Small things matter. God is in the details.
- It is through practice in the small that professionals gain proficiency and trust for practice in the large.
- The smallest bit of sloppy construction, of the door that does not close tightly, or slightly crooked tiles on the floor, or even the messy desk dispel the charm of the larger whole.
- In software, 80% or more of what we do is quaintly called “maintenance”: the act of repair. Good software practice requires such discipline: focus, present of mind and thinking. The 5S philosophy comprises these concepts:
- Sort. Knowing where things are.
- Systematize. A place for everything, and everything is in its place.
- Shine. Keep the workplace free of hanging wires, grease, scraps, and waste.
- Standardization. Agree about how to keep the workplace clean.
- Self-discipline. That means having the discipline to follow the practice and to frequently reflect on one’s work and be willing to change.
-
Making your code readable is as important as making it executable.
-
Cleanliness is next to godliness.
- He who is faithful in little is faithful in much.
- An ounce of preventions is worth a pound of cure.
- Pay attention to small things, but also be honest in small things.
- Do our best to leave campground cleaner than we found it.
- To err is human, to forgive, divine.
- A clean shop floor reduces accidents and well-organized shop tools increase productivity.
Introduction
Writing clean code requires craftsmanship. Craftsmanship is acquired through knowledge and work. You must gain the knowledge of principles, patterns, practices and heuristics that a craftsman knows and you must also grind that knowledge into your fingers, eyes and gut by working hard and practicing.
Clean Code
Cost of bad code.
- Dad code slows down productivity over time. It’s unprofessional for programmer to bend to the will of managers who don’t understand the risks of making messes. You will not make the deadline by making the mess. The only way to go fast is to keep the code as clean as possible all the time.
- One broken window starts the process of decay. A building with broken windows looks like nobody cares about it. So other people stop caring. They allow more windows to become broken. Eventually they actively break them. They allow facade with graffiti and allow garbage to collect.
What is clean code?
-
I like my code to be elegant and clean. The logic should be straightforward to make it hard for bugs to hide, the dependencies minimal to ease maintenance, error handling complete according to an articulated strategy, performance close to optimal so as not to tempt people to make the code messy with unprincipled optimizations. Clean code does one thing well. - Bjarne Stroustrup, inventor of C++.
-
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscure the designer’s intent but rather is full of crisp abstraction and straightforward line of controls. - Grady Booch, author of Object Oriented Analysis and Design with Application.
-
I could list all of the qualities that I notice in clean code, but there is one overarching quality that leads to all of them. Clean code always looks like it was written by someone who cares. There is nothing obvious that you can do to make it better. All of those things were thought about by the code’s author, and if you try to imagine improvements, you’re led back to where you are, sitting in appreciation of the code someone left for you—code left by someone who cares deeply about the craft. - Micheal Feathers.
Books on art don’t promise to make you an artist. All they can do is to give you some of the tools, techniques and thought process that other artists have used. “Code-sense” can only be gained through practice.