c++學編程如何鍛煉耐力
by Amy M Haddad
通過艾米·M·哈達德(Amy M Haddad)
我如何學習編程:這是一項耐力運動 (How I’m learning to program: it’s an endurance sport)
為什么我的編程學習軌跡反映了我作為跑步者的訓練方式 (Why my learning trajectory for programming mirrors my training regime as a runner)
I’ve read stories about people trying to learn programming at breakneck speed — programming daily for a dozen-plus hours for a few months in order to learn programming fast. I’ve also read about the aftereffects of this approach: feeling burned out and taking a long break from programming.
我讀過一些有關人們試圖以驚人的速度學習編程的故事-為了快速學習編程,每天都要進行幾十個小時以上的編程。 我還讀到了這種方法的后遺癥:感覺疲倦,并且在編程上花了很長時間。
There’s nothing quick about learning to program, at least in my experience. It not only takes time to learn — and really understand — the vast amount of material involved. But it also takes time to learn to think like a programmer.
至少從我的經驗來看,學習編程并沒有很快。 學習并真正理解所涉及的大量材料不僅需要時間。 但是學習像程序員一樣思考也需要時間。
That’s why I see learning to program as an endurance sport. As a former long-distance runner, that’s one reason why I enjoy it so much. In fact, my learning trajectory for programming mirrors my training regimen as a runner. It’s about having a plan, setting a steady pace, and persevering.
這就是為什么我將學習編程視為一項耐力運動。 作為一名前長跑運動員,這就是我非常喜歡它的原因之一。 實際上,我的編程學習軌跡反映了我作為跑步者的訓練方式。 這是關于制定計劃,設定穩定的步伐和堅持不懈的方法。
通過計劃建立耐力 (Build Endurance with a Plan)
My first half-marathon was memorable for all of the wrong reasons. The running conditions weren’t great: it was unusually warm May day in Indiana and the route offered little shade. But these were the least of my concerns. With my face flushed, heart pounding, and my legs like steel poles, I felt completely out of shape — because I was. I hadn’t followed a training plan, like most runners do.
由于種種錯誤的原因,我上半場馬拉松令人難忘。 行駛條件不是很好:印第安納州五月天氣異常溫暖,路線幾乎沒有陰影。 但這是我最不擔心的。 臉紅了,心臟跳動,雙腿像鋼管一樣,我感覺完全不舒服-因為我是。 我沒有像大多數跑步者那樣遵循訓練計劃。
I learned my lesson, and used a training plan for every race thereafter. These training plans provided several months of workouts that prepared me for the race ahead. They also got me the results I wanted: I dropped dozens of minutes from my race time and felt great doing it.
我吸取了教訓,然后為每場比賽使用了訓練計劃。 這些訓練計劃提供了幾個月的鍛煉,這使我為接下來的比賽做好了準備。 他們也給我帶來了我想要的結果:我從比賽時間里摔了幾十分鐘,感覺很棒。
Today, I follow a different training plan: one for learning to program. It gives my studies structure, holds me accountable, and helps me get the most out of my programming hours.
今天,我遵循另一種培訓計劃:一種學習編程的計劃。 它為我提供學習結構,讓我負責,并幫助我充分利用編程時間。
It all starts with a quarterly plan, which guides my learning for the next few months. When I ran, I followed different training plans based on the race I was running or the time I was after. Now I create and follow quarterly plans with a specific learning objective. This quarter, for example, it’s learning computer science fundamentals using Python.
這一切都始于一個季度計劃,該計劃將指導我接下來的幾個月的學習。 跑步時,我會根據自己參加的比賽或比賽的時間遵循不同的訓練計劃。 現在,我創建并遵循具有特定學習目標的季度計劃。 例如,本季度將使用Python學習計算機科學基礎知識。
Once a plan is in place, I identify resources to help me achieve my goals. Then, I make it happen by creating weekly and daily plans, which help me budget my time and identify my focus for the day ahead. That way, I enter each programming session with purpose and know exactly what I need to do.
一旦制定了計劃,我就會確定可以幫助我實現目標的資源。 然后,我通過創建每周和每日計劃來實現這一目標,這有助于我預算時間并確定未來的工作重點。 這樣,我有目的地進入每個編程會話,并且確切地知道我需要做什么。
By following a running program, I knew how many miles I needed to run and how fast I needed to run them. It’s no different with programming. There was no guessing what I should do this morning when I opened up my laptop. I had those details figured out last night when I created a plan for the day ahead. As a result, I dove right into the problem set I needed to complete.
通過遵循一個正在運行的程序,我知道我需要運行多少英里,以及運行它們需要多快。 編程沒有什么不同。 今天早上我打開筆記本電腦時,沒有任何猜測。 昨晚我為前一天創建計劃時,已經弄清了那些細節。 結果,我完全了解了我需要完成的問題集。
This planning process is not just a nice feature to have — it’s a necessity for me. My time is limited because I work full time and am learning to program outside of work hours. So I need every minute spent programming to count. My programming plan helps make that happen.
這個計劃過程不僅是一個不錯的功能,而且對我來說是必需的。 我的時間有限,因為我全職工作并且正在學習在工作時間以外編程。 所以我需要花每一分鐘來編程。 我的編程計劃有助于實現這一目標。
你的步伐是什么? (What’s your Pace?)
It was a crisp, sunny November morning when I toed the line for a half-marathon. Before the race began, I noticed a group of runners huddled together; one was holding a flag with their race pace on it. “I’ll stick with that group,” I said to myself, and off I went. I should’ve known better.
十一月是一個清脆,陽光明媚的早晨,我參加了半程馬拉松比賽。 在比賽開始之前,我注意到一群跑步者擠在一起。 一個人拿著旗幟,上面標著他們的比賽節奏。 “我會堅持那個小組的。”我對自己說,然后離開了。 我應該知道的更好。
This group was going far faster than I’d trained for. My time was looking great at the five-mile mark, but my energy was soon sapped. I couldn’t keep the group’s sprint-like pace for the next 8.1 miles. But by the time I slowed down the damage was done. I had started out way too fast and exerted a lot of energy in the process, making the remainder of the race long and laborious.
這個小組的進度比我訓練的要快得多。 在五英里處,我的時間看上去很棒,但是我的精力很快就耗盡了。 在接下來的8.1英里比賽中,我無法跟上小組沖刺般的步伐。 但是到我放慢腳步的時候,傷害已經完成了。 我起步太快,并且在此過程中投入了大量精力,使得比賽的其余部分漫長而費力。
Starting off in a sprint will give you a dramatic head start, as I learned from that race. But it’s not sustainable for the long-term if you’ve got a lot of ground to cover. Consistency is crucial. It mattered when I was running long distances and it still matters now as I’m learning to program.
正如我從那場比賽中學到的那樣,以短跑起步將帶給您戲劇性的領先優勢。 但是,如果您有很多方面需要解決,那么從長遠來看,這是不可持續的。 一致性至關重要。 當我長跑時很重要,現在當我學習編程時仍然很重要。
At 5:25 each morning my alarm startles me awake. I head for my standing desk, where I spend the next few hours programming. These precious hours are mine to chisel away on my daily programming goal before my day job begins. No all-nighters. No 16-hour days spent programming on the weekend. Instead I pour a few hours of focused effort each day, six days per week, into becoming a better programmer.
每天早上5:25,我的鬧鐘驚醒我。 我前往自己的站立式辦公桌,在接下來的幾個小時中,我將在其中進行編程。 在我的日常工作開始之前,這些寶貴的時間可用來消除我的日常編程目標。 沒有通宵。 周末無需花16個小時的時間進行編程。 取而代之的是,我每天(每周六天)投入數小時的精力來成為一名更好的程序員。
It’s not just the number of hours I spend programming, but how I spend them. Again, it’s a question of pace. Society pressures us to move fast in just about everything we do. However, I’ve found that approach doesn’t work — especially when it comes to learning. If I move too quickly, I overlook small but important concepts or get concepts mixed up. Plus some things, like recursion, take time to understand.
這不僅是我花費在編程上的時間,還包括我如何花時間。 同樣,這是步調問題。 社會向我們施加壓力,要求我們在所做的一切事情中都必須Swift采取行動。 但是,我發現這種方法行不通-尤其是在學習方面。 如果我移動得太快,我會忽略一些小而重要的概念,或者混淆一些概念。 再加上一些東西,例如遞歸,需要一些時間來理解。
So the hours I spend programming are steady. I make sure I really understand the material or problem before moving on. This process involves a lot of repetition, which means I move slower. I admit that it’s hard to hold back, so I constantly need to remind myself that I’m building a foundation of knowledge. If I rush the process now, I’ll regret it down the road.
因此,我花在編程上的時間很穩定。 在繼續之前,我確保我真的了解材料或問題。 這個過程涉及很多重復 ,這意味著我移動得更慢。 我承認很難忍受,所以我經常需要提醒自己,我正在建立知識基礎。 如果我現在著急進行此程序,那我會后悔的。
This pace is also sustainable for me. It’s a pace I’ve kept since I began learning to program and it’s helping me get where I want to go.
這個速度對我來說也是可持續的。 自從我開始學習編程以來,這就是我一直保持的步伐,它可以幫助我到達想要去的地方。
一致性事項 (Consistency Matters)
There’s a lot to like about consistency. For one, it makes learning manageable. Because I program a few hours each day, I’m focused on a just a small chunk at a time.
關于一致性,有很多令人喜歡的東西。 首先,它使學習變得易于管理。 因為我每天要編程幾個小時,所以我一次只專注于一小部分。
Today that chunk was understanding a sorting algorithm and getting practice with it. Other times it’s getting a test or two to pass. These are manageable goals. They challenge me, but they’re definitely doable.
如今,那部分知識是了解排序算法并開始實踐。 其他時候,它會通過一兩次測試。 這些是可管理的目標。 他們挑戰我,但絕對可行。
Consistency also helps me with recall. When I use various data structures on a regular basis, I remember when and how to use them. They’re fresh on my mind when I start a new problem. Not surprisingly, my confidence increases, too. The more I use regular expressions, for example, the more comfortable I get with them.
一致性也有助于我回憶。 當我定期使用各種數據結構時,我會記得何時以及如何使用它們。 當我提出新問題時,它們在我腦海中是新鮮的。 毫不奇怪,我的信心也增加了。 例如,我使用正則表達式的次數越多,對它們的使用就越舒適。
I see progress more quickly with consistent effort because small, incremental improvements add up over time. Take recursion as an example. I certainly didn’t “get it” on my first pass, or even on the second or third. In fact, I’d been struggling with this concept for a while. Each study session has helped me progress, albeit slowly, from understanding the basic idea, to completing very simple problems and eventually more challenging problems. The culmination of daily study and practice paid off because it’s finally clicked.
我看到通過不懈的努力可以更快地取得進展,因為隨著時間的推移,小的,漸進的改進會累加起來。 以遞歸為例。 我的第一遍,甚至第二遍或第三遍,我當然都沒有“得到”。 實際上,我已經為這個概念苦苦掙扎了一段時間。 每個學習環節都幫助我進步,盡管速度很慢,但從理解基本概念到完成非常簡單的問題以及最終更具挑戰性的問題。 每天的學習和實踐的高潮得到了回報,因為它終于被點擊了。
Perhaps most important of all, consistency is sustainable for the long-term. If I put in a few hours of quality programming today, then I know I’ll have the energy to do it again tomorrow, the next day, next week, next month, and for the remainder of the quarter, until a new plan begins and the process starts again.
也許最重要的是,一致性可以長期持續。 如果我今天投入幾個小時進行質量編程,那么我知道明天,第二天,下周,下個月以及本季度的剩余時間里,我將有足夠的精力去做,直到新計劃開始然后該過程再次開始。
Consistent doesn’t mean easy. I feel comfortably challenged with my programming pace, though it’s taken some time to figure out the best pace for me. Going at a consistent pace, be it in running or programming, keeps a bit of energy in the tank. That way, when you’re really struggling you’ll have something in reserve to finish strong.
一致并不意味著容易。 盡管我花了一些時間來找出最適合自己的速度,但我對自己的編程速度卻感到很挑戰。 無論是在運行還是在編程中,始終如一的步伐可以使儲罐內保持一點能量。 這樣,當您真正掙扎時,您將有一些儲備來完成強項。
堅持不懈 (Persevere)
When you’re running 20-plus miles, your legs feel like lead. You’re tired and hungry, and ready to stop. And yet you forge on.
當您跑步20英里以上時,腿部感覺就像鉛一樣。 您又累又餓,準備停下來。 然而,你繼續前進。
It takes time to build the physical endurance to run that much, not to mention the mental stamina to see it through. Programming is the same way. Rare is the day that I solve a problem in just minutes. Problems can take me weeks to solve, and I get more bugs and failed tests than I’d care to admit.
要花那么多時間才能建立起身體的耐力,更不用說精神耐力了。 編程是相同的方式。 難得的一天是我在短短幾分鐘之內解決了一個問題。 問題可能需要花費我數周的時間才能解決,而且我得到的錯誤和失敗的測試超出了我所愿意承認的范圍。
But I show up each day and persevere, realizing that small wins matter. My aim is to get incrementally better: get one more test to pass or get fewer error messages. Similarly, during a long run, I’d tell myself “ok, just one more mile.” And when I’d get to that mile marker I’d tell myself again “ok, just one more mile.” In both cases, despite the challenges or discomfort, I’m inching my way closer to the end goal through sheer willpower.
但是我每天都堅持不懈,意識到小小的勝利很重要。 我的目標是逐漸變得更好:再進行一次測試以通過或減少錯誤消息。 同樣,從長遠來看,我會告訴自己“好,再走一英里。” 當我得到到英里標記我會再告訴自己,“好了,只是一個更英里。” 在這兩種情況下,盡管面臨挑戰或不適,但我都將通過純粹的意志力向最終目標邁進。
The feeling of accomplishment after solving a tough problem is like the one I got when I crossed the finish line of a race or finished a long, tedious run. All of that time, effort, and mental turmoil were worth it.
解決了一個棘手的問題后的成就感,就像我越過比賽的終點線或完成漫長而乏味的奔跑時得到的那種感覺。 所有這些時間,精力和精神動蕩都是值得的。
There are some things in life that are quick to learn. Programming is not one of them, in my opinion. Once you get started, you realize how much there really is to learn — and it’s a lot! That makes it exciting, but it also makes consistency that much more important. I haven’t been programming too long. The race just started for me — and it’s a marathon, not a sprint.
生活中有些事情可以快速學習。 我認為編程不是其中之一。 一旦開始,您就會意識到真正需要學習的東西-很多! 這使它變得令人興奮,但同時也使一致性變得更加重要。 我沒有編程太久。 比賽對我來說才剛剛開始-這是一場馬拉松,而不是短跑。
I’m a writer (amymhaddad.com), and a beginner programmer.
我是作家( amymhaddad.com )和初學者。
翻譯自: https://www.freecodecamp.org/news/how-im-learning-to-program-it-s-an-endurance-sport-8bf8725cd38/
c++學編程如何鍛煉耐力