Leave your code better than you found it. Please note this does *not* say “never write comments.” Instead, expressive code requires less commenting and is cleaner. So what? The reason this matters is that incorrect comments might take a future developer down the wrong path. When commenting extensively, you now need to maintain the comments, as well as the code. While comments are important, code should speak for itself whenever possible. Comments are often lies waiting to happen. Clean code reads like well-written prose. For example, name methods in such a way that the method name explains what it does. Things in your code should explain what they do in their names. If you do this, later in your editing session, and next week, next week and next year, you’ll know exactly what that variable is referring to. You don’t tell your doctor to skip washing their hands because it saves time. You are responsible for the quality of your code. So how do you write clean code? What do you actually do? According to Toppa, there are 10 things you can start to do today. “We spend most of our time staring into the abyss rather than power typing.” ~ Douglas Crockford Clean code makes better use of that reading time. In other words, the actual time spent typing is significantly less than the time spent reading, even in development. Martin notes that the ratio of reading code to writing code is 10:1. Writing in Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. When it comes to writing code, an ounce of prevention is worth a pound of cure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |