Navigation
Search
|
The discipline of great code
Wednesday August 27, 2025. 11:00 AM , from InfoWorld
One of my favorite TV shows is The Bear. It’s a show about a troubled yet brilliant chef, his family, his friends, and the restaurant they all start together. It’s also about excellence and growing into greatness.
The Bear includes what might be the best television episode I have ever seen. In Season 2, Episode 7, called “Forks,” a main character, Richie, spends a week at a top-tier restaurant to learn how things are done. Interestingly, what Richie does most of the week is polish and arrange the forks. At first, he resents it, but as the week goes on, he comes to understand the precision and discipline required to become a Michelin three-star restaurant. That lesson, of course, translates into most areas of life—especially coding. To be a great coder, I believe, you need to have extreme discipline, take profound care with every aspect of your code, and never compromise on excellence. I’ve seen a lot of code over the years. Some of that code was written by brilliant developers, and some was written by developers who were, well, not brilliant. Beautiful code The first thing I always note about brilliant code is that it looks good. The code is pleasing to the eye. It is formatted properly and consistently. The methods are small and concise. Nothing in the code “drifts right,” indicating deeply nested conditional statements. It just looks right. You know good code when you see it. A big part of good-looking code is formatting. Formatting code correctly takes care—and a disciplined automation system. Many teams use automated formatting tools, as they should. A brilliant developer will endeavor to format his code so that the formatter doesn’t change a thing. Putting that kind of care and attention to detail into how your code looks will carry over into how your code performs. Properly formatted code should be a point of pride. Taking care to write your code correctly the first time is indicative of a precise mind that strives to write correct code and keep things properly in order at all times. I don’t care what formatting rules you follow—way too many pixels have been burned arguing about that. Just have a set of rules and follow them assiduously. After making sure that the code is properly formatted, the brilliant and precise coder will ensure that the coding linter is not emitting anything at all. A linter will alert you to syntax errors, style issues, potential bugs, potential security issues, and the violation of any other rules that your particular language might warrant. Just as with formatting, writing your code with care so that the linter has nothing to complain about is indicative of how proper your code is to do the task it is supposed to do. Brilliant code In other words, taking care of the small and precise details will help to ensure that the big picture will be taken care of. If you don’t get the little things right, the big things won’t be right either. Writing clean code, just like polishing forks, becomes a habit. Repetition can be seen as tedious, or it can be seen as perfecting a craft. I suspect that Richie was a better fork polisher on Friday than he was on Monday. Friday’s forks were probably more thoroughly polished, more precisely stacked, and more efficiently cleaned. In the same way, good coding habits practiced over and over will lead to better code over time. One person’s tedium is another person’s process of perfection. Excellence, of course, is contagious. Richie was tasked with polishing forks. But he noticed that someone else was charged with spoons, and others with knives and pots and, most importantly, the food. Being precise, being thorough, being meticulous—all of this spreads throughout an organization. If you insist on it, others will become precise and exacting as well, and they in turn will motivate others. If you set a strong example, the contagion of quality will spread through a whole organization. In a restaurant, no one notices perfectly clean, polished forks. But everyone would notice if the forks were not clean and polished. Just as a good restaurant takes extreme care with every detail, a brilliant coder takes great care with every detail of her code. A developer coming upon beautiful code that pays close attention to detail might not notice the care taken, but he will realize that bad code is buggy, hard to fix, and difficult to understand.
https://www.infoworld.com/article/4045662/the-discipline-of-great-code.html
Related News |
25 sources
Current Date
Aug, Thu 28 - 00:06 CEST
|