如何成為一個優秀的程序員
by Amy M Haddad
通過艾米·M·哈達德(Amy M Haddad)
如何成為一名優秀的程序員 (How to be a great programmer)
What sets apart the really great programmers?
是什么使真正出色的程序員與眾不同?
As we all know, great programmers build amazing features, websites, apps, and the like. But what do they have in common?
眾所周知,優秀的程序員會構建出色的功能,網站,應用程序等。 但是它們有什么共同點?
In my research, it’s not just about knowing a language really well or having a particular educational background. It’s that the really talented programmers have mastered the fundamentals. That foundation is what enables them to build great things and come up with breakthrough ideas.
在我的研究中,這不只是真正了解一種語言或具有特定的教育背景。 才華橫溢的程序員已經掌握了基礎知識。 這個基礎使他們能夠構建偉大的事物并提出突破性的想法。
Think of a pyramid. It has a large base, but gradually gets smaller and thinner toward the top. Learning the fundamentals of programming forms that base. Everything takes off from there.
想想一個金字塔。 它的底面很大,但逐漸向頂部變小變細。 學習編程基礎的基礎。 一切都從那里起飛。
So what are those fundamentals? Based on my experience and the programmers whose backgrounds I’ve researched, I see programming fundamentals as a two-part approach.
那么這些基本原理是什么? 根據我的經驗以及研究過背景的程序員,我將編程基礎知識分為兩部分。
問題解決者非凡 (Problem Solver Extraordinaire)
First, you have to be an effective problem solver. This is an important place to start since programming is problem-solving.
首先,您必須是有效的問題解決者。 這是一個重要的起點,因為編程可以解決問題。
Although there are many ways to solve a problem, there are a few parts of the process that stand out to me. Programmers who are also great problem solvers distill a problem to its essence, in order to identify their overall aim and begin a problem with purpose. Then, they break each problem into small, manageable parts — attacking each part in turn, and sometimes in visual terms by drawing a picture to make it “real world.”
盡管有很多方法可以解決問題,但是過程中的一些部分對我很突出。 也是偉大的解決問題者的程序員,從本質上講問題,以便確定他們的總體目標,并從目的著手解決問題。 然后,他們將每個問題分解成可管理的小部分–依次攻擊每個部分,有時還通過繪制圖片使其成為“真實世界”來以視覺方式進行攻擊。
The process is harder than it sounds. When I started to program, I hit a wall: like many others, I never learned how to problem solve in school; it’s a skill that’s not readily taught. I was given a problem set in math class and just dove in, which is what I did when I started to program. Unsurprisingly, I was spinning my wheels unnecessarily and hitting roadblocks on the simplest of problems.
這個過程比聽起來困難。 當我開始編程時,我遇到了麻煩:像許多其他人一樣,我從未在學校學習過如何解決問題的方法; 這是一項不易教授的技能。 我在數學課上遇到了一個問題,只是開始學習,這就是我開始編程時所做的。 毫不奇怪,我不必要地打了個轉輪,就最簡單的問題打了障礙。
Things began to change when I began learning about the problem solving process, and how to problem solve effectively. I now begin a problem with intent. I have George Polya’s book, How to Solve It, to thank for that bit of advice.
當我開始學習問題解決過程以及如何有效解決問題時,事情開始發生變化。 我現在開始意圖問題。 感謝George Polya的書《 如何解決它》 。
I’ve adapted some of Polya’s ideas to programming, like understanding the problem. “The problem must be understood,” Polya writes. This includes being able to “point out the principal parts of the problem, the unknown, the data and the condition.” For each problem, I pull out a sheet of paper and write answers to these questions: what am I solving for or trying to find? (unknown); what am I given? (data); and what constraints or details do I need to be aware of? (condition).
我已經將Polya的一些想法應用于編程,例如理解問題。 “必須理解問題,” Polya寫道。 這包括能夠“指出問題的主要部分,未知,數據和狀況。” 對于每個問題,我都會抽出一張紙并寫下以下問題的答案:我要解決或試圖找到什么? (未知); 我得到什么? (數據); 我需要注意哪些約束條件或細節? (健康)狀況)。
Understanding the problem may seem obvious, but the obvious is easily overlooked. On more than one occasion, I’ve poured hours into a problem only to realize much later that I missed a small, but critical detail in the problem statement. Writing out problem details slows me down mentally, and helps me think through exactly what I need to do, which is half of the battle.
理解問題似乎很明顯,但顯而易見的事實很容易被忽略。 在不止一次的情況下,我花了很多時間解決問題,但后來才意識到我錯過了問題陳述中一個很小但很關鍵的細節。 寫出問題的詳細信息會使我的思想減慢,并幫助我仔細考慮需要做的事情,這是成功的一半。
From there, I make a plan, which is another of Polya’s suggestions. It makes sense. I write an outline before I write an article. An artist makes a sketch of the painting before working on the painting itself. A builder uses drawings and blueprints to build a house. It’s no different with programming. Instead of rushing into doing, I need to start by thinking about what I’m setting out to do and make a plan of attack.
從那里,我制定了一個計劃,這是Polya的另一個建議。 這說得通。 在寫文章之前,我先寫大綱。 在進行繪畫本身工作之前,藝術家會先繪制繪畫草圖。 建筑商使用圖紙和藍圖建造房屋。 編程沒有什么不同。 我不必急著去做 ,而是要開始思考我打算做的事情并制定進攻計劃。
There are many ways to go about this. Sometimes I outline the steps I need to take in numerical order: first do this, second do that. Other times I make the problem visual. When I was learning about for loops, I pulled out a handful of almonds and physically iterated through the pile. It’s a silly example, but it helped me think through the problem.
有很多方法可以解決此問題。 有時,我會按數字順序列出需要采取的步驟:首先執行此操作,然后執行此操作。 其他時候,我將問題可視化。 當我學習循環時,我抽出了少數杏仁,并在堆中進行了物理迭代。 這是一個愚蠢的例子,但是它幫助我思考了這個問題。
I’ll also draw pictures or diagrams. For a recursive problem, I’ll draw a diagram of what’s happening on each recursive call until I hit the base case. Almost always, however, I find a way to simplify the problem to make it more manageable and to help me spot a pattern. Above all, the aim for me is to enter a problem with purpose, and maintain that sense of purpose throughout.
我還將繪制圖片或圖表。 對于遞歸問題,我將畫出每個遞歸調用發生的情況的圖表,直到找到基本情況為止。 但是,幾乎總是可以找到一種方法來簡化問題,使其更易于管理,并幫助我確定模式。 最重要的是,對我來說,目的是解決有目的的問題,并始終保持這種目的感。
Despite the best made plans, problems are still hard and I still get stuck. Becoming a great problem solver takes time; it’s a skill I’m still working on and it’s definitely worth the effort. It’s a difference you can see.
盡管制定了最好的計劃,但問題仍然很棘手,我仍然陷入困境。 成為一個出色的問題解決者需要時間。 這是我仍在努力的一項技能,絕對值得付出努力。 您可以看到差異。
When I read code written by a great problem solver, it’s clean and easy to understand. Variables are well named. Functions are short and crisp. Each line of code has a specific purpose; the fluff is removed. The clarity of the code mirrors the programmer’s thought-process: I can read the program from top to bottom and know exactly what’s going on. That’s great problem solving, and that’s what I’m striving for.
當我閱讀由出色的問題解決者編寫的代碼時,它很干凈而且易于理解。 變量是很好的命名。 功能簡短。 每行代碼都有特定的用途。 絨毛被去除。 代碼的清晰性反映了程序員的思想過程:我可以從上至下閱讀程序,并確切地知道發生了什么。 那是解決問題的好方法,而這正是我所追求的。
那你的電腦呢? (What about your Computer?)
Learning computer science is the second programming fundamental. I recently started learning computer science, and love it because I’m moving beyond surface level. I’m going “behind the scenes” to learn what happens when I use a built-in function, for example. I’m also learning about memory and run time, among many other topics. In short, I’m learning why a computer does the things it does.
學習計算機科學是第二個編程基礎。 我最近開始學習計算機科學,并喜歡它,因為我已經超越了表面層面。 例如,我將“在幕后”學習使用內置函數時會發生什么。 我還正在學習有關內存和運行時間的許多其他主題。 簡而言之,我正在學習為什么計算機可以完成其工作。
Knowing the “why” enhances my contextual knowledge and makes me a more informed programmer. As a result, I’m more thoughtful with the code I write. Now that I know a bit about run time, for instance, I’ll opt to use a binary search instead of iterating through each element in a list.
知道“為什么”會增強我的上下文知識,并使我成為一個更有見識的程序員。 結果,我對編寫的代碼更加體貼。 例如,現在我對運行時有所了解,我將選擇使用二進制搜索而不是遍歷列表中的每個元素。
It’s also enriching my understanding of how core programming concepts work. For example, I was working on a recursive problem and I wasn’t getting the solution I anticipated. After close examination, I learned why: it had to do with the execution of the call stack, an idea that would’ve escaped me just a few months ago.
這也豐富了我對核心編程概念如何工作的理解。 例如,我正在處理一個遞歸問題,但沒有得到我期望的解決方案。 經過仔細檢查,我了解了原因:它與調用堆棧的執行有關,這種想法在幾個月前就沒能對我產生作用。
Or take classes. I struggled immensely with classes for the longest time, and was terrified to use one. I knew how to write a class, but wasn’t confident when and why I’d use one. That changed when I learned what actually happens in my computer when I create instances and call methods. It finally clicked, once I had some context. For both recursion and classes, computer science bridged gaps in my knowledge.
或參加課程。 我花了很長時間在課堂上苦苦掙扎,并為使用一個而感到恐懼。 我知道如何寫一堂課,但是我不確定何時以及為什么要使用一堂課。 當我了解創建實例和調用方法時計算機中實際發生的情況時,情況發生了變化。 一旦我有了一些上下文,它終于點擊了。 對于遞歸和課堂,計算機科學彌合了我的知識空白。
All too often, the fundamentals get pushed aside. Progress can be slow, and people tend to pick more “fun” stuff to work on when given the option. That’s a shame. Programmers who master the fundamentals seem to code with confidence: they know the “how” and “why” of their programming choices, which improves their work and builds their credibility with others.
很多時候,基本面被拋在一邊。 進展可能會很慢,并且如果有選擇,人們會傾向于選擇更多的“有趣”東西來進行工作。 真可惜 掌握基礎知識的程序員似乎對代碼充滿信心:他們知道編程選擇的“方式”和“原因”,從而改善了工作并建立了與他人的信譽。
Plus, a solid grasp of the fundamentals makes learning new languages and technologies easier to do. For example, taking the time to really understand core concepts like iteration, recursion, and abstraction with one language will help when learning another. Simply put, there’s a lot to gain and little to lose by mastering the fundamentals.
另外,扎實的基礎知識使學習新語言和新技術變得更加容易。 例如,花點時間真正了解一種語言的核心概念,例如迭代,遞歸和抽象將對學習另一種語言有所幫助。 簡而言之,掌握基礎知識可以帶來很多收獲,而沒有損失。
I’m a writer (amymhaddad.com), and a beginner programmer.
我是作家( amymhaddad.com )和初學者。
翻譯自: https://www.freecodecamp.org/news/how-to-be-a-great-programmer-34939494996d/
如何成為一個優秀的程序員