老程序员推荐10个编程策略

英文原文: http://erniepark.com/software/2014/08/20/10-practical-software-engineer-tips.html

译文: http://netsmell.com/post/10-practical-software-engineer-tips.html


1.橡皮鸭debug法

也许大家都有过这样的经历,那就是当你在和别人讨论问题时,突然就有了答案和别的想法,这是因为当你和别人一起讨论时会让你的大脑重新组织问题,这样的情况下,你的聊天对象就是“橡皮鸭”。所以我们每个人都应该积极主动的成为对方的“橡皮鸭”,这样我们彼此才有可能得到好的建议。

2.信息反馈要及时

如果写好了代码,就怎该马上到你的讨论区里去讨论下,和你的“橡皮鸭”们交流下,听下他们的建议,因为现在纠正可比你做成成品后改动要节约成本的多.

3.换种方式思考

当你冥思苦想得不到你想要的答案时,你不妨先离开下你的工作岗位,换种方式和地点思考,这种方法有时真的很有效,身边有很多朋友在聊天时也会说起这种方式,有时在你上厕所或是打个盹时真得就能想到你想要的答案,有要不信。总之,换个环境真的对你有帮助。

4.自动化的好处

很多程序员都认为自动化只是能做到节约时间,这完全是一个误解。他不只是如此,自动化最大的优点是他可以让你的思想没有阻碍,可以朝着目标勇往直前。假设我们常要运行一些复杂的查询,而且每次都要重新输入一遍,当然,你应该不会真的傻乎乎的这么做,大家都会使用剪贴板或是其他的工具,我认为自动化是更为有效的。

5.善用“拿来主义”

我们都希望写出完美的新代码,有新的抽象概念。可当我们设计新代码时,抽象概念又成了我们的困扰。当我有这种困扰时,我不是马上思考各种抽象概念,而是先复制一些代码作为原型。这样就可以上手新项目了,而且效果也不错,不过要记住一点,不要只复制,还要清理代码,不然就会很难收拾。

6.适当的运动是很有必要的

因为常常要做在电脑旁很久,所以久坐使我们经常腰酸背痛。因些想要有个好的身体就要常运动,不然什么都是白费。每周至少三次超过1时间的运动大家都很难坚持。

如果你真的像我所说的难以坚持的话,不妨试下立式桌,他是可能站立也可以坐下的,这样就可以轻松的在上班时解决久坐不动的问题。

7.了解前面的文章

每当自己阅读新的文章时总是有些地方让人搞不清楚状况,为了能更好的阅读和理解文章,大家最好先看下这篇文章的前文才好,这样才能更好的帮助我们理解当前的文章。

8.记录笔记

有些人可以对自己的记忆很有自信,所以对这种记笔记的办法很不屑,但我是会每天都做笔记的,把所以遇到的问题和如何解决这些问题的方法详细的记录下来,等现碰到这些问题时很快就能解决掉,我敢打赌,就算你有再好的记忆也会有一些事情记不清楚,所以拿起纸和笔记录起来。

9.提前做好计划

在一天工作完毕后我都会把第二天的工作做的计划表,这样到了第二天就不会太盲目,目标也很明确。这种方法对于第二天的工作真的有质量上的提高和速度上的加快。

10.总结

上述所有的内容不一定对每个人都有用,但这也是个人很长时间从事开发一来的经验之谈,希望对大家有所帮助。

英文原文:


10 Practical Tips for Software Engineers

20 Aug 2014

Here are a few simple tips and strategies I've picked up over my (short) career. See what works for you! Share your own with me on Twitter.

1. Be a rubber ducky, find a rubber ducky

Have you ever talked to someone about a problem then realized the solution as you were describing it? This happens all the time. Talking out loud often gives your mind clarity and organization around a problem. In scenarios like this, the person you are talking to is considered a rubber ducky. Everyone on your team should be open to being a rubber ducky and talking to one. Sometimes, if you're lucky, the rubber duckies will even offer good suggestions.

2. Get feedback fast

Try to get feedback on code as soon as it makes sense. If you're working on a Pull Request flow like we do at HubSpot, make some trivial change and open the PR as soon as you can so you have a place to discuss design and code. Talk to your rubber duckies and make them quack! It's cheaper to iterate on prototypes than a 'finished' product.

Depending on how your team is structured, this might mean not writing code at all initially. Mockups, designs on a whiteboard, etc. are a lot cheaper to throw out than hundreds of lines of code.

3. Get End-to-End first

When working on a new problem or feature, it's very easy to dive right into the nitty gritty details. I've found a better approach is to get end to end as quickly as possible (or alternatively, to a "Hello world").

For example, say I needed a user click on a web page to trigger some complicated calculation, then save some results to a server. You might want to dive right into figuring out how to do the meaty calculation. For me, a better approach is to set up the event handler for the user action, mock the calculation with some fixed values, and then fire the API request to the server. This way, I can test my system end to end before I've figured out every detail. I now have a feedback loop which helps me iterate and code faster. The design might not be perfect initially, but by seeing how things fit together, you get a clearer picture of the full system you're trying to design.

At HubSpot, we take this concept even further by pushing features to production before they're even finished so that we can test them internally. We can do this because of our gating infrastructure (more on this another time).

4. Know when to step away from the keyboard

Sometimes, putting in debuggers, console.logging everywhere, and just bashing at the keyboard is a good way to test code. Other times, when you're having a tough time managing a complex design or problem, you need to stop looking at your screen. It's silly but sometimes I solve problems or have great insights in the bathroom. My wife, who is also a software engineer, does her best thinking when she sleeps (literally as she's falling asleep, or sometimes even in dreams...). Take a nap, go for a walk, go to the bathroom, whatever, but find ways to think away from your computer.

5. Automate

It's no secret that efficient developers automate many of their tedious processes. A common misconception about automation though is that it's only about saving time. While saving time is certainly valuable, the larger point is that automation allows you to chase a train of thought uninterrupted and lowers the barrier for actually completing tasks.

For instance, if there was a complex SQL query I needed to run very often to get some metrics, I am much less inclined to run the query if it is long and I have to type it every time. If instead, I've saved it on my clipboard using a program like Alfred, or saved it somewhere for easy access, I'm much more likely to run the query often.

6. You can always DRY off later

It's tempting to write perfect code and figure out every abstraction when you're designing new code. I've found that abstractions are dangerous time sinks when starting on something new, even when they seem obvious and easy to design. Rather than abstract right away, I'll simply copy paste large chunks of code as I'm prototyping. It helps me move quicker on new projects at the beginning and often times reveals better abstractions and concerns than I could have discovered on a piece of paper or whiteboard. Of course the caveat is that you have to actually clean up the code before it rots.

7. Stay mobile

Mobile as in your body, not your iPhone. Coding doesn't burn too many calories so it's important to force yourself to stay active. Make sure to get a good stretch in a few times a day and walk around from time to time. At HubSpot, we have a club that does pushups before lunch three days a week. I like to do a few pushups every hour or so to keep my blood flowing and muscles stretched.

Sitting for long periods of time has caused me intense shoulder and back pain in the past, but having a standing desk has eliminated those pains completely. I'd strongly suggest trying it out for short periods of time if you experience pain related to sitting. At HubSpot we have motorized desks so I can switch between standing and sitting. I didn't feel like shelling out $1000 for a fancy desk at home, so I was able to find one on Craigslist for $40.

8. Read ahead

Reading documentation, technical articles, and code can often be confusing and maddening. Before flailing your arms and scratching your head, read ahead a bit and get more context. Programming concepts are difficult to express in a linear form. Reading ahead will often make it more clear what a previous sentence or code snippet is talking about.

9. Write meticulous notes

This tip might not jive with the less organized devs out there. I take meticulous notes in Evernote every single day about what I've worked on, problems I've encountered, and how I've solved them. These notes have become invaluable to me whenever I encounter a problem that I know I've solved in the past but can't recall the solution to. It also has the added benefit of helping you recall your accomplishments when its time to have a 1 on 1 or performance review.

10. Plan for tomorrow, today

Either before I go home for the day, or at night at home, I make myself a todo list in Evernote of what I'd like to accomplish the next day. Then when I get into work the next morning, I am focused and have a clear agenda so I can hit the ground running. Personally, getting a good, productive start to the day often carries through the rest of the morning and afternoon.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值