TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Writing maintainable code is a communication skill

297 pointsby hakuninover 3 years ago

22 comments

wbsunover 3 years ago
Sometime it is not the programmers that don&#x27;t know the benefits of maintainable code or how to write it, it is the culture that rewards short-term velocity instead of long-term reliability. I&#x27;ve seen <i>superstars</i> designing shitty system and writing messy code to workaround processes and policies to launch quickly, and as a reward, they are promoted like taking rockets. It would be really hard for others to not follow the same path as long as the company needs to make money. Long-term benefits are hard to demonstrate while short-term feature&#x2F;product launches are so obvious.
评论 #29437682 未加载
评论 #29435417 未加载
agentultraover 3 years ago
From the opening of <i>Structure and Interpretation of Computer Programs</i> [0] there is the famous aphorism, &quot;Programs are meant to be read by humans and only incidentally for computers to execute.&quot;<p>I&#x27;ve been programming for over twenty years. Try as I might to produce code that expresses the problem eloquently and succinctly to unfold the solution in the readers&#x27; understanding as they skim through the source... it has rarely ever worked. Firstly you cannot please everyone. And secondly, programs are not structured for pedagogy.<p>Writing maintainable code is a communication skill but I find the best skills are writing, speaking, and illustrating concepts in prose, specifications, white board sessions, chats, etc.<p>The technicalities of ensuring code follows some kind of style guide, design principles, etc plays a big part. But nothing will explain &quot;why&quot; or the big picture stuff quite like a specification or blog post in my experience.<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Structure_and_Interpretation_of_Computer_Programs" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Structure_and_Interpretation_o...</a><p><i>Update</i>: added missing link
评论 #29432691 未加载
评论 #29432466 未加载
评论 #29434361 未加载
评论 #29436220 未加载
iamwilover 3 years ago
I usually have the opposite problem. I end up writing clean code because it&#x27;s the only way I can keep everything in my head, and hence can keep things straight. But it does make me a slower programmer than others, since maintainability takes thoughtfulness, which takes time.<p>That doesn&#x27;t seem to get rewarded in startups, because often times, your goal is to test the startup hypothesis--and you end up throwing away code anyway. I think only two of my code bases have survived to this day in my whole career.<p>I am convinced that it pays to be faster, since you have more times at bat trying out ideas. I have adjusted and found some ways to eschew clean up because it doesn&#x27;t matter in the long run, but I&#x27;m still struggling to find the right balance after all these years.<p>Anyone out there have heuristics that helps them with this struggle?
评论 #29435595 未加载
评论 #29435594 未加载
daenzover 3 years ago
&gt;How often have you seen an algorithm expressed with such grace that it appears boringly obvious?<p>There is a perverse quality that I see in mostly junior engineers of not wanting the complicated thing to appear simple. I think it&#x27;s probably a result of some ego and accomplishment and wanting others to know it was challenging. I&#x27;m not sure exactly but I&#x27;ve seen it a lot.
评论 #29434952 未加载
评论 #29432108 未加载
评论 #29431932 未加载
sdevonoesover 3 years ago
I found out that some fellow engineers do not want to write maintainable code, they instead want to write code that:<p>- follows SOLID principles<p>- follows Clean Code principles<p>- follows Hexagonal architecture principles<p>- ...<p>Sometimes such principles do lead to maintainable code, but, most of the time they don&#x27;t (at least in my limited working experience of around 10 years). An example: If you duplicate code because at the end it seems to be the proper way to write a piece of functionality that will be easier to maintain in the future (and most importantly, it communicates clearly its intention)... well, that&#x27;s a no-go for some fellow engineers because, somehow, that violates all or some of the principles they have read in some blog post owned by internet celebrities.
评论 #29431908 未加载
评论 #29431997 未加载
评论 #29432145 未加载
评论 #29433163 未加载
评论 #29439891 未加载
评论 #29434198 未加载
exabrialover 3 years ago
The problem is &quot;writing maintainable code&quot; doesn&#x27;t stroke the ego quite like &quot;writing impressive code&quot;
评论 #29439012 未加载
jasonpeacockover 3 years ago
The challenge is, how do you teach it?<p>Like many writers, many coders think their code <i>is</i> readable and are resistant to feedback. They literally do not see the problem.<p>You can institute all the rules and guidelines you want, but they see it as friction and overhead and only do it because they are forced to.
评论 #29431802 未加载
评论 #29431790 未加载
评论 #29432438 未加载
评论 #29431736 未加载
zujover 3 years ago
Haven’t come across this before but I can see myself using this framework of how, what and why in the future.<p>Few thoughts…<p>How: Talking as a mid level programmer, I can’t control the language of choice, I can’t influence the framework or the design. I can control how the individual piece of algorithm is written.<p>What: Apart from the function names, the main important thing here is abstraction. Abstraction is a long term game and it improves with your understanding. The abstraction you choose with a few weeks of exposure to the domain will be entirely different when compared to the person who knows the domain for 10 years.<p>Your abstractions can also changes with the exposure to the actual problem in hand. The more you go down the rabbit hole the more abstraction will keep changing.<p>I like what Kent says here… <a href="https:&#x2F;&#x2F;kentcdodds.com&#x2F;blog&#x2F;aha-programming" rel="nofollow">https:&#x2F;&#x2F;kentcdodds.com&#x2F;blog&#x2F;aha-programming</a><p>As the author says, it takes years to develop the overall taste but also it takes time to find the right abstraction for solving the problem in the domain.<p>Why: Never thought of comments as the why. I used to think of comments as what more than why. Simple but important distinction.<p>Thanks for the insights.
评论 #29443788 未加载
tpoacherover 3 years ago
It&#x27;s politeness first, and skill second.<p>Most people don&#x27;t lack skill per se; they just don&#x27;t give a shit about you.
评论 #29433782 未加载
评论 #29434248 未加载
lambdabaover 3 years ago
In other words, code should be eloquent, it should be as easy as possible to understand why it exists and why the way it is written is correct (or give information as to why the author thought it was correct).<p>Likewise, with regard to modularity, I like the take on codebases that optimize for deletion and not abstraction (after all, abstraction is only a tool, not an objective).<p>These two together make up for the best code IMO.
bloopernovaover 3 years ago
I&#x27;ve found that documentation is one of the first things to go when time-constrained in Sprints. The PM&#x2F;PO or Team Lead will pay lip service to the idea of allotted time to documentation writing for each Story, but don&#x27;t enforce that during planning. Nor do they call it out during Retros.<p>Heck, there&#x27;s some devs, senior and junior, who don&#x27;t realize the value of standard branch naming, ticket references in commit messages, etc etc. Or they&#x27;ll pay lip service (again) to a conventions standard, but still continue to work the old way over and over.<p>The common thread among devs that I&#x27;ve spoken to is that they feel they aren&#x27;t talented enough to write good docs, that they don&#x27;t have time, and that they don&#x27;t know what to write about. I feel like the team lead and higher-ups need to focus on enforcing standards for a few sprints to get everyone working on the same page.
FjgdymdjttdjGover 3 years ago
I interviewed someone from China once who wrote code almost as I write prose.<p>FirstWeCreateAVariableCalledX.AssignItValueY().PassYtoPvalue();<p>Now imagine 10,000 lines of code written like this and done so in a way that was thoroughly impressive. The creativity alone was startling. I would do it a disservice to further explain.<p>Yes, her object names were ridiculously long, but it was the most readable code ever. It was like she combined the code and documentation together. I&#x27;d seen this neither before nor since, and it was strange and beautiful.
layer8over 3 years ago
The hardest problem is to adequately foresee the context and the background knowledge future maintainers will have.<p>* Context will change due to modifications and added features in the surrounding code.<p>* One tends to overestimate how much background knowledge a future maintainer will have.<p>* One tends to misjudge which parts of the necessary knowledge will be externally available &#x2F; still &quot;obvious&quot; in the future.
abernard1over 3 years ago
I took issue with this quote<p>&gt; “Isolating complexity in a place where it will never be seen is almost as good as eliminating the complexity entirely.” — John Ousterhout<p>If you can isolate the complexity in one place, it isn&#x27;t complex. It means that it is definitionally simple and separable.<p>There are things which cannot possibly be isolated and they are complex. Examples are idempotency, things that deal with synchronization or time, resource management across multiple entities.<p>It seems pedantic, but this insight is remarkable in effective system design. If you figure out the inherently complex non-negotiables ahead of time, the rest of your solution becomes pipe-fitting. A large percentage of modern software these days is lost because they start with pipe-fitting and just move the complexity of their problem around endlessly, never identifying it.
elurgover 3 years ago
Yes, writing maintainable code requires the ability to explain.<p>There is far far more to &quot;communication skills&quot; than explaining yourself very well, stuff like negotiation and persuasion and conflict resolution. Most of those are less relevant to writing code as much as to getting it accepted.
joe_the_userover 3 years ago
My experience has been, the next guy always thinks it&#x27;s the last guy&#x27;s fault. But actually the fault usually winds being that of the next guy - even when I was the next guy.<p>Programmers are impatient, we look at the code, the code looks <i>terrible</i>. We lay into with a hatchet and three days later, it works. But there&#x27;s a very minor problem. You look at the problem, look at it again. Three more days and you&#x27;ve ripped out your code completely, done apologies to the ancestors of the last guy and finally his work and all the problem are solved.<p>And the comment? The communication? No one read them, they made no sense. But once you complete the code, you realize no other comments could have sufficed.
jet_32951over 3 years ago
There is a parallel to this comment that is not much thought about in mechanical CAD: some designers use tools that get the job done, but the model breaks if you look at it funny. It is all too easy to fall in this trap unless management is willing to pay for models that are maintainable and not just quickly moved out the door. Asking engineers to use the &quot;principle of least astonishment&quot; and develop work others can maintain is difficult at first. It&#x27;s inculcating the idea of model maintainability and then supporting it against budget constraints that takes the work.
chiefalchemistover 3 years ago
Communication? Maybe. But in my mind it&#x27;s more of a user experience. That is, someone else picks up your &quot;product&quot; (i.e., code), how easy - or not - is it for them to engage with that product?
torresmoover 3 years ago
I consider maintainability and readability related, but two different things. I&#x27;d expect maintainable code to be readable. However, I&#x27;ve encountered code bases that were easy to read, but hard to maintain. I mean that the code was hard to change after new requirements came up.<p>So when writing some code, a programmer needs to have some good understanding on how the business requirements might evolve, and design the code with that in mind, so the next programmer can not only easily read the code, but also change it in face of new requirements.
评论 #29438689 未加载
revskillover 3 years ago
It&#x27;s about good abstraction.<p>&quot;If a piece of code could be abstracted, it&#x27;ll eventually be extracted.&quot;
wintorezover 3 years ago
Software development is communication; writing code is a side-activity.
b0rsukover 3 years ago
If you have one group of coders writing new functionality, and another doing maintenance work on the application, you have diverging interests. The &quot;new functionality&quot; people have an incentive to rush stuff, because bugfixes won&#x27;t be their responsibility anyway. The most cynical way to do this is writing a lot of new functionality, put it on CV, and leave for another company.
评论 #29433861 未加载