TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What Programming Habit Changed Your Code for the Better?

4 点作者 alexliu51811 个月前
Hey everyone!<p>We often talk about tools, languages, and new technologies that help us improve our coding. However, today I&#x27;d like to focus on the habits and practices that make us better developers.<p>1. *What is one programming habit you’ve adopted that has significantly improved the quality or efficiency of your code?* 2. *How did you come to adopt this habit, and what impact has it had on your development process or outcomes?*<p>This could be anything from a specific way you comment your code, to how you structure your workday, to a particular approach to debugging or testing. I&#x27;m looking forward to learning about the routines that have made a real difference in your work!

2 条评论

myst11 个月前
Writing the design doc before writing the program. I was &quot;gently forced&quot; into that at a past job. When I write a design doc, I think about a problem in terms of the problem, rather than the (arbitrarily) chosen tech stack. As a result, the solution is (in)validated quicker, the program is simpler, better fitting the problem and significantly easier to understand, and the programming phase converges to a reliable solution much faster.
nicopappl11 个月前
Tooling<p>When your text editor is not enough for a task, and it hopefully is extensible, consider writing little plugins to reduce repetitive tasks.<p>Here is an example. I was working with a legacy code base using an infamous Scala actor framework. Basically, all function calls were replaced by message passing. All messages were sent as &#x27;Any&#x27; objects, then downcast to the expected type, so an IDE wasn&#x27;t of much use. I wrote a little bash script to populate a jump buffer in vim with the result of a grep, and suddenly, I had jump functionality! Originally, I had to jump to type definition, hope that the associated &quot;received message&quot; type was in the same file, then look for downcasting into that received type. I don&#x27;t remember precisely the details, but what I do remember is that the little script helped go from a few seconds to just pressing two keys to navigate the code. It&#x27;s especially useful for legacy code, where the main activity associated with it is reading and understanding.<p>Our capacity to focus as humans is limited in time and energy. Writing tools to do in half a second what otherwise would take a few seconds can help, not only to make you faster (for that, refer to xkcd 1205) but also to effectively increase your capacity to focus.<p>Though being able to develop your own tooling is less important today. Languages and frameworks nowadays prioritize tooling as an important feature. And I&#x27;m grateful for that, programming used to be much more annoying.