當前位置

首頁 > 英語閱讀 > 雙語新聞 > JQuery之父: 每天都來點代碼吧

JQuery之父: 每天都來點代碼吧

推薦人: 來源: 閱讀: 2.44W 次

Last fall, work on my coding side projects came to a head: I wasn’t making adequate progress and I couldn’t find a way to get more done without sacrificing my ability to do effective work at Khan Academy.

去年秋天我的業餘編程項目(coding side projects)到了一個緊要關頭:沒有充足的進度,也不能夠找到一種方法在既不犧牲我可汗學院(Khan Academy)高效的工作的前提下完成更多的事情。

There were a few major problems with how I was working on my side projects. I was primarily working on them during the weekends and sometimes in the evenings during the week. This is a strategy that does not work well for me, as it turns out. I was burdened with an incredible amount of stress to try and complete as much high quality work as possible during the weekend (and if I was unable to it felt like a failure). This was a problem as there’s no guarantee that every weekend will be free – nor that I’ll want to program all day for two days (removing any chance of relaxation or doing anything fun).

JQuery之父: 每天都來點代碼吧

如何處理我的業餘編程項目是有一些嚴重問題的。我最主要是在週末或者某些工作日的晚上編寫代碼。如同結果一樣,這種策略並不適合我。週末我拖着巨大的壓力嘗試完成儘可能多的高質量代碼(如果我沒能完成我會認爲自己很失敗)。這樣想有一個問題,因爲沒有什麼能夠保證我每個週末都有空,並且想整個週末都寫程序而不是抓緊機會放鬆或娛樂。

There’s also the issue that a week between working on some code is a long time, it’s very easy to forget what you were working on or what you left off on (even if you keep notes). Not to mention if you miss a weekend you end up with a two week gap as a result. That massive multi-week context switch can be deadly (I’ve had many side projects die due to attention starvation like that).

每週寫代碼之間空擋太長也是個問題。你很容易忘記在做什麼、什麼還沒做完(即使做記錄也於事無補)。更不用說如果你錯過一個週末,你就會面對長達兩週的間隔。大量兩週或者更多周的思維轉換可是致命的(我的很多業餘項目都由於精力不足而終止)。

Inspired by the incredible work that Jennifer Dewalt completed last year, in which she taught herself programming by building 180 web sites in 180 days, I felt compelled to try a similar tactic: working on my side projects every single day.

我被Jennifer Dewalt去年完成的工作震驚了,她在180天內構建了180個網站以學習編程。受到她的啓發,我強迫自己嘗試一個相似的策略:每一天都要進行我的業餘項目。

I decided to set a couple rules for myself:

我決定給自己制定一些規則:

1.I must write code every day. I can write docs, or blog posts, or other things but it must be in addition to the code that I write.

1.我必須每天都寫代碼。我可以寫文檔,博客或其他的東西。但必須依附於我所寫的代碼。

must be useful code. No tweaking indentation, no code re-formatting, and if at all possible no refactoring. (All these things are permitted, but not as the exclusive work of the day.)

2.代碼必須是有用的。不能代碼微調,不能代碼重排,且儘量不要重構。(這些事情都是允許的,但不作爲當天特有的工作。)

code must be written before midnight.

3.所有代碼必須在午夜前寫。

code must be Open Source and up on Github.

4.代碼必須開源且放在Github上。

Some of these rules were arbitrary. The code doesn’t technically need to be written before midnight of the day of but I wanted to avoid staying up too late writing sloppy code. Neither does the code have to be Open Source or up on Github. This just forced me to be more mindful of the code that I was writing (thinking about reusability and deciding to create modules earlier in the process).

其中的一些規則有點武斷。雖然從技術上來講代碼沒必要非得在午夜前寫,但我想要避免熬夜太久寫糟糕的代碼。而且代碼沒必要開源放在Github上。這只是強迫我寫代碼時多上點心(想想重用以及決定開發過程早點寫模塊)。

Thus far I’ve been very successful, I’m nearing 20 weeks of consecutive work. I wanted to write about it as it’s completely changed how I code and has had a substantial impact upon my life and psyche.

到目前爲止我進行得很順利,我已進行了20周的連續工作。我想要寫下這些是因爲這方法完全改變了我的編碼方式並且對我的生活以及心智都有實質性的影響。

With this in mind a number of interesting things happened as a result of this change in habit:

有這些規則後,習慣的改變導致了很多有趣的事情發生:

Minimum viable code. I was forced to write code for no less than 30 minutes a day. (It’s really hard to write meaningful code in less time, especially after remembering where you left off the day before.) Some week days I work a little bit more (usually no more than an hour) and on weekends I’m sometimes able to work a full day.

最少可行代碼(Minimum viable code).每天我被強迫寫至少30分鐘的代碼。(少量時間內很難寫出有意義的代碼,尤其是在記起前一天寫到哪裏後)有一些工作日我寫得多點,但通常少於1小時。而週末,我有時候能一整天當程序猿。

Code as habit. It’s important to note that that I don’t particularly care about the outward perception of the above Github chart. I think that’s the most important take away from this experiment: this is about a change that you’re making in your life for yourself not a change that you’re making to satisfy someone else’s perception of your work. The same goes for any form of dieting or exercise: if you don’t care about improving yourself then you’ll never actually succeed.

編碼即爲習慣(Code as habit).其實重要的一點是我並不特別在意Github上的(負面)聊天內容是如何被他人理解的。我認爲這是從這個實驗中我學到的最重要的東西:這是關於在你一生中爲了你自己而進行的改變而非爲了讓你的工作能討好他人而進行的改變。這也適用於任何形式的節食或鍛鍊:如果你不在意提高自己,你是永遠也不會成功的。

Battling anxiety. Prior to starting this experiment I would frequently feel a high level of anxiety over not having completed “enough” work or made “enough” progress (both of which are relatively unquantifiable as my side projects had no specific deadlines). I realized that the feeling of making progress is just as important as making actual progress. This was an eye-opener. Once I started to make consistent progress every day the anxiety started to melt away. I felt at peace with the amount of work that I was getting done and I no longer had the over-bearing desire to frantically get any work done.

抵抗焦慮(Battling anxiety).在開始這個實驗之前我經常擔心不能夠完成足夠多的工作量或者取得足夠的進展(這兩點很難度量,因爲我的業餘項目沒有明確的截止日期)。我發現想要取得進展與實際取得進展是同樣的重要。這讓我豁然開朗。一旦我開始每天取得持續的進展,焦慮就開始消失了。我對我不斷完成的工作量感到欣慰,並且我不再過度瘋狂地期望完成更多的工作。

Weekends. Getting work done on weekends use to be absolutely critical towards making forward momentum (as they were, typically, the only time in which I got significant side project coding done). That’s not so much the case now – and that’s a good thing. Building up a weeks-worth of expectations about what I should accomplish during the weekend only ended up leaving me disappointed. I was rarely able to complete all the work that I wanted and it forced me to reject other weekend activities that I enjoyed (eating dim sum, visiting museums, going to the park, spending time with my partner, etc.) in favor of getting more work done. I strongly feel that while side projects are really important they should not be to the exclusion of life in general.

週末(Weekends).在週末完成的任務曾今對於推進進度是絕對重要的。的確有地表性地,這是我完成業餘項目顯著代碼量的唯一時間。但現在並非如此,不過非常好。在週末完成我一整週所期望的有價值的內容只能以讓我以失望告終。我極少能夠完成我想要完成的所有工作,而這強迫我放棄其他週末我喜歡的活動(例如,吃中式點心,參觀博物館,去公園以及和我的小夥伴在一起玩等)以完成更多的工作。雖然我非常相信業餘項目真的很重要,但總之,他們不應該阻礙你的平時生活。

Background processing. An interesting side effect of writing side project code every day is that your current task is frequently running in the back of your mind. Thus when I go for a walk, or take a shower, or any of the other non-brain-using activities I participate in, I’m thinking about what I’m going to be coding later and finding a good way to solve that problem. This did not happen when I was working on the code once a week, or every other week. Instead that time was consumed thinking about some other task or, usually, replaced with anxiety over not getting any side project work done.

發呆(Background processing).每天都寫業餘項目的一個有趣的副作用就是當前業餘項目的任務會頻繁地在你大腦中浮現。這導致當我走路,洗澡或則進行其他不耗費腦力的活動時,我總是在想接下來我要寫些什麼代碼並且尋找好的方法來解決問題(譯者注:別人看來就是發呆)。這在我每週或隔一週寫一次代碼的時候從未出現過。相反這些時間花費在了思考其他的一些任務上,通常是懊惱自己上週沒能完成業餘項目的工作量。

Context switch. There’s always going to be a context switch cost when resuming work on a side project. Unfortunately it’s extremely hard to resume thinking about a project after an entire week of working on another task. Daily work has been quite helpful in this regard as the time period between work is much shorter, making it easier to remember what I was working on.

思維轉換(Context switch). 繼續業餘項目時總是會有思維轉換代價的。不幸的是,當一整週都在幹其他任務的工作時,這轉變是及其困難的。就每天都寫代碼而言是非常有利的,因爲工作間歇時間更短。這使得回憶起正在做什麼更容易。

Work balance. One of the most important aspects of this change was in simply learning how to better balance work/life/side project. Knowing that I was going to have to work on the project every single day I had to get better at balancing my time. If I was scheduled to go out in the evening, and not get back until late, then I would need to work on my side project early in the day, before starting my main Khan Academy work. Additionally if I hadn’t finished my work yet, and I was out late, then I’d hurry back home to finish it up (instead of missing a day). I should note that I’ve been finding that I have less time to spend on hobbies (such as woodblock printing) but that’s a reasonable tradeoff that I’ll need to live with.

工作權衡(Work balance). 這個改變最重要的一方面是直接學會了如何更好地權衡工作/生活/業餘項目。由於明確了我每天都會工作在業餘項目上,我必須更好地平衡我的時間。如果我計劃晚上外出並且會很晚纔回來,那麼我會在一天中早些時候,既在開始我的可汗學院的主要工作前,完成我的業餘項目的工作量。而且如果我沒有完成我的任務,並且在外待得很晚,我會趕回家完成他而不遺漏一天。我應該注意到了我擁有更少地時間可花費在愛好上(例如版畫),但這是我需要面對的合理的折衷。

Outward perception. This has all had the added benefit of communicating this new habit externally. My partner understands that I have to finish this work every day, and thus activities sometimes have to be scheduled around it. It’s of considerable comfort to be able to say “Yes, we can go out/watch a movie/etc. but I have to get my coding in later” and have that be understood and taken into consideration.

他人看法(Outward perception). 把這個新的習慣告訴別人讓我更受益。我的小夥伴理解我需要每天完成這個工作,因此有的時候活動安排也很遷就我的工作。能夠說“沒問題,我們可以出去玩/看電影/等,但我等會兒要當會兒程序猿”並且能夠被理解和考慮在內是相當欣慰的。

How much code was written? I have a hard time believing how much code I’ve written over the past few months. I created a couple new web sites, re-wrote some frameworks, and created a ton of new node modules. I’ve written so much I sometimes forget the things I’ve made – work from even a few weeks prior seem like a distant memory. I’m extremely pleased with the amount of work that I’ve gotten done.

能寫多少代碼?我簡直不敢相信我上個月寫了多少代碼。我製作了一堆新的網站,重寫一些框架,並且創建了大量新的節點模塊(node modules)。我寫了如此的多,以至於我有時候都忘記了我到底幹了些什麼,前一週的工作都好像是很遙遠的記憶樣。我對我所完成的工作量是及其滿意的。

I consider this change in habit to be a massive success and hope to continue it for as long as I can. In the meantime I’ll do all that I can to recommend this tactic to others who wish to get substantial side project work done. Let me know if this technique does, or doesn’t, work for you – I’m very interested in hearing additional anecdotes!

我認爲這個習慣改變是一個很大的成功並且希望能儘可能地繼續下去。與此同時,我將傾盡所有將這個策略推薦給其他希望讓其業餘項目有實質進展的人。無論這個技術對於你是有用或者沒用,請告訴我。我會非常樂意聽更多的趣事的!