The hidden value of automation in programming comes from saving mental context switches
嗯,用户让我总结一篇文章的内容,控制在100字以内,而且不需要用“文章内容总结”之类的开头。好的,先看看文章讲了什么。 文章主要讨论编程社区里的一个常见笑话:花在创建提高生产力的工具上的时间,往往比工具实际节省的时间更多。作者提到两个xkcd漫画来支持这个观点。接着,作者指出这种观点忽略了上下文切换的成本。 举个例子,比如Web开发者在开发和生产URL之间切换。手动操作可能需要3到5秒,而花一小时写一个Chrome扩展来自动化这个过程是否值得呢?计算下来,只有每天做一次这个动作持续近3年才划算。但作者认为,真正的好处在于消除上下文切换带来的干扰。即使任务本身时间不长,频繁的切换也会打断工作流程。 所以,总结的时候要抓住关键点:编程社区的笑话、工具开发时间与节省时间的关系、上下文切换成本的重要性、以及消除干扰带来的好处。 控制在100字以内的话,可能需要简化一些细节。比如提到编程社区的笑话、工具的时间投入与产出、上下文切换的成本以及其对工作效率的影响。 最后组织语言,确保简洁明了。 </think> 编程社区常调侃编写工具的时间远超工具节省的时间。然而,手动操作的上下文切换成本同样重要。例如,开发者在开发和生产URL间切换看似简单,但频繁的中断会严重影响专注力和效率。 2020-1-18 23:21:31 Author: blog.jonlu.ca(查看原文) 阅读量:0 收藏

It's a pretty common joke in the programming community that you'll spend a lot more time writing a tool to improve productivity than the amount of time that that tool actually saves you. So much so, in fact that there's actually two xkcd's on the subject.

xkcd

https://xkcd.com/1205/

xkcd

https://xkcd.com/1319/

However, what this ignores is the actual cost of the context switch associated with the action or problem you're eliminating.

For instance imagine the fairly common action of switching between a development URL and a production URL for a web developer. You can be working on https://mysite.com and instead and need to switch over to https://dev-env1.mysite-dev.com.

This is an action that takes seconds at most. You move the cursor up, click in, highlight the domain, and replace it with the subdomain and domain of your dev environment.

If you're fast, you don't even use a cursor and instead use ⌘ + L to select the URL, then use the arrow keys and a shift modifier to select and overwrite the full domain. This takes probably takes between 3 to 5 seconds from start to finish.

To make this faster, you could spend around an hour writing a chrome extension that automatically switches between the development URL and the production URL at a keystroke. Hit ⌘ + Shift + P and the URL gets rewritten and toggled between prod and dev, and you are navigated to the page (you obviously are a good engineer and document your code, add tests, and learn best practices for the chrome extension.)

To have this be worth it, in a purely objective amount of time sense, you'd have to do this action:

3,600 seconds (60 minutes) / 4 seconds (on average) = 900 times

This would only be worth it if you do this action once a day for a little under 3 years. Anything less and the amount of time spent building the tool is greater than the benefits.

The real benefit of automating repetitive tasks like this, though, comes from removing the context switch that comes with the manual action. It's often true that a large investment that doesn't make sense based on total amount of time still has outsized impact due to the lack of context switches.

If the required action or task that could be automated is intensive enough, it can be enough to completely throw off your mental model of what you're working on. This varies person by person, but it's not unreasonable to believe something that is relatively short (15 seconds) can be enough to distract you from whatever problem you're working on.

It's a bigger issue to have a flow-ruining context switch than to lose a few hours building something that ensures the former won't happen again.

Context switches for programmers

<a href=


文章来源: https://blog.jonlu.ca/posts/context-switches
如有侵权请联系:admin#unsafe.sh