如何成为一个优秀的程序员
by Amy M Haddad
通过艾米·M·哈达德(Amy M Haddad)
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.
那么这些基本原理是什么? 根据我的经验以及研究过背景的程序员,我将编程基础知识分为两部分。
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.
当我阅读由出色的问题解决者编写的代码时,它很干净而且易于理解。 变量是很好的命名。 功能简短。 每行代码都有特定的用途。 绒毛被去除。 代码的清晰性反映了程序员的思想过程:我可以从上至下阅读程序,并确切地知道发生了什么。 那是解决问题的好方法,而这正是我所追求的。
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/
如何成为一个优秀的程序员