Principles For Programmers - Andrei Neagoie
Principles For Programmers - Andrei Neagoie
v1.0.0
Subscribe to get updates and new principles as this book evolves at zerotomastery.io
i
Preface
Advice is easy to give. That is why advice that is given should always
be inspected, debated, and analyzed. What may have worked for one
individual will not necessarily work for everyone or in all situations.
At the same time, as humans, we are able to learn from the past and
stand on the shoulders of giants. This way, we don’t make the same
mistakes over and over. Instead, we get to learn from the mistakes of
the past so that we start on our journey along a path that isn’t
completely unknown. If we are able to jump start from other’s
experiences, and be efficient in our learning, that is a winning strategy
that will take us far.
This is the reason for this book. For the past 5 years, I have been
collecting advice, articles, books and opinions of some of the best
programmers, thought leaders, and business people that I know. I
wanted to collect ideas from people with different opinions, and narrow
ii
down these recommendations to the core and essence. Sometimes I
include principles coming from my own experience, but the goal of this
book is to combine not just my own advice, but to combine the advice
of the top performers and find the commonalities between them so that
you don’t have to start from the very beginning.
Whether you are just learning to code, or you have many years of
experience in the industry, you should find something actionable and
valuable in this book for your own situation.
This book is not meant to be read in one sitting. Each principle will
offer its own value. Think of these as tidbits that you can read every
once in a while, come back to, or be reminded of something important,
so that you make sure you are on the correct path to success.
iii
PRINCIPLE 1
4
It's impossible to imagine a future 10 years from now where a customer comes
up and says, "Jeff, I love Amazon; I just wish the prices were a little higher." "I
love Amazon; I just wish you'd deliver a little more slowly." Impossible. When
you have something that you know is true, even over the long term, you can
afford to put a lot of energy into it.
— JEFF BEZOS
5
PRINCIPLE 2
Helping others
without answers
6
PRINCIPLE 3
Beware of the
half-life
Everything we know, not just about programming, has an expiration.
The half-life of knowledge is a term to denote the time it takes for half
the knowledge in a domain to be outdated. According to one study, the
half life of an engineer in 1930 was 35 years vs 10 years in 1960 .
1
1. https://spectrum.ieee.org/riskfactor/computing/it/an-engineering-career-only-a-young-persons-game
7
PRINCIPLE 4
Experience is not
created equal
10 years coding by yourself with no other programmers around you,
with no code reviews, doesn’t necessarily make you better than
someone who has 1 year of coding experience working on a project
with team members and getting code reviews daily. Get out of your
bubble. Work with others, be surrounded by other programmers and
learn from them. The biggest thing you can do if you are starting out is
to get hired as soon as possible so you can work with others to
accelerate your learning. Let others see your work. Get feedback.
That’s how you gain experience.
8
PRINCIPLE 5
9
PRINCIPLE 6
10
PRINCIPLE 7
Treat non
technical people
with respect
Be respectful to those who are not technical. Everyone has their own
strengths. Instead of judging, try to help, try to communicate, and try to
learn from them. Patience and respect goes a long way. This is an
opportunity for you to practice your communication skills to deliver your
message.
11
PRINCIPLE 8
12
PRINCIPLE 9
13
P R I N C I P L E 10
14
If you can’t explain something in simple terms, you don’t understand it.
— RICHARD FEYNMAN
15
P R I N C I P L E 11
Divide and
Conquer
16
Controlling complexity is the essence of computer programming.
— BRIAN KERNIGHAN
17
P R I N C I P L E 12
It is always easier
to add than to
subtract
Writing code is easy. Removing it is hard. Adding a new feature to a
product is easy. Removing it might break the system, or may result in
angry customers. Addition leads to more chances for errors and
mismanagement. As a programmer, we are paid to improve the value of
the business. Every time you write code or introduce third-party
services, you are introducing the possibility of failure into your system.
The number of lines of code you write does not make you a better
programmer. Your job isn’t to write code. You are not paid to code. It’s
2
to add value . Many times, less is actually more.
2. https://bravenewgeek.com/you-are-not-paid-to-write-code/
18
Measuring programming progress by lines of code is like measuring aircraft
building progress by weight.
— B I L L G AT E S
19
P R I N C I P L E 13
The ability to explain why you chose this particular solution or why
you chose this tool over alternatives is a sign of a great programmer.
Don’t just tell people. Explain yourself and give evidence for your
thinking. Don’t do things because you read it in a blog post. Be able to
explain the “why” of what you are doing. If you are able to explain with
evidence, you are ahead of most.
20
P R I N C I P L E 14
Notice technical
debt
3. https://www.csc.gov.sg/articles/how-to-build-good-software
21
There are only two hard things in Computer Science: cache invalidation and
naming things.
— P H I L K A R LT O N
22
P R I N C I P L E 15
Compound interest
of learning
We overestimate what we can do in the short term. We
underestimate what we can do in the long term. Learn the concept of
compound interest. This doesn’t apply just to money. It applies to
knowledge. When we learn something new we feel like we will never
get there. You see someone you admire and think that you will never be
able to get there. Of course you won’t…in the short term. However, if
you are able to learn each day just a little bit, eventually you will get
there. The key is to keep improving every day, and keep learning. Years
from now you will look back and realize how far you have come. We
miss deadlines all the time because of short term optimism, but long
term, we can accomplish a lot more than we think. A little bit of learning
every day will always trump trying to learn a lot in a short period.
23
P R I N C I P L E 16
The 2 teachers
24
P R I N C I P L E 17
A good programmer knows to pick what tool to use and when. This
doesn’t mean you have to learn every single tool under the sun. You
need to understand what tools exist and the pros and cons of each so
you can make a smart decision of what to pick when the time arises.
Remember this: Find the right tool or system to use. Learn how to
customize them to fit your unique requirements and fix problems
discovered along the way.
25
P R I N C I P L E 18
26
P R I N C I P L E 19
If you are using code you don’t understand, stop. Understand it first
4
before you add it into your project . Learn from the solutions of others,
but you should understand what you add to your projects.
4. https://daedtech.com/5-things-ive-learned-in-20-years-of-programming/
27
PRINCIPLE 20
Working code is
not always right
Just because the code is working, it doesn’t mean it’s right. Working
code is great, but does not necessarily represent the optimal solution.
Working code is just one step in an iterative process of continuously
improving and adapting our code to the situation. This is why the first
solution to your problem is not necessarily always the right one.
28
Simplicity is the ultimate sophistication.
— LEONARDO DA VINCI
29
P R I N C I P L E 21
A good programmer fixes the right problems, not all problems. There
is limited time and limited resources. The good programmer is able to
prioritize and focus on what matters most.
30
The art of debugging is figuring out what you really told your program to do
rather than what you thought you told it to do.
— ANDREW SINGER
31
PRINCIPLE 22
The secret to
empathy
32
PRINCIPLE 23
33
Premature optimization is the root of all evil.
— DONALD KNUTH
34
PRINCIPLE 24
There is no Yoda
35
PRINCIPLE 25
Don’t obsess
about best
practices
Best practices are not always going to last. Good practices with our
current level of understanding and tools is a better way to look at
things. What may be good now may not be the best in the future. Be
open to change and be open to different opinions and thoughts.
Sometimes the ideas that cause the most controversy today will turn
into the best practices one day, and those in turn will one day become
outdated.
36
I was too busy looking at the trees in front of me to see the forest all around.
— FA M O U S P R O V E R B
37
PRINCIPLE 26
38
PRINCIPLE 27
Learn to Say No
39
PRINCIPLE 28
Ask questions
40
PRINCIPLE 29
There is one
constant in this
world
There is no right and wrong. Only pros and cons. Every situation,
every library, every opinion, every line of code, offers a pro and con to a
specific subject. The less you see things as black and white, the more
you are able to think in terms of a balance and tradeoffs.
41
PRINCIPLE 30
There is no
perfect
All products, all projects, all codebases have bugs, complexities and
issues. You can always make things better. There is no perfect tech
stack. Don’t be that programmer that complains about how poorly
somebody has written this piece of code. You don’t know the context
and the time limits the person had. Just understand that nothing is
perfect. Everything can be improved, or made worse. Accept it.
42
Perfect is the enemy of good.
— V O LT A I R E
43
P R I N C I P L E 31
Depth, then
Breadth
Narrow your focus at the beginning of your career. Figure out the
chosen path to getting hired and focus deeply on the subject that you
know you will get hired with. From there, once you feel you truly know
the subject, expand to other languages, fields or topics. Trying to do too
many things at once and learning everything at once is a recipe for
disaster. You can only do one thing well at a time. Do that, then look
beyond.
44
PRINCIPLE 32
Know-it-alls are
never all
knowing
Don’t be a know it all. If you have real world experience, and you are
speaking from experience, then do so. Provide context to your opinion,
but don’t just say things because you read it in a blog post or you heard
someone say it online. Form your own opinions, and be open to others’
opinions. No matter how much experience you have, you will always
have gaps in your knowledge that can be filled by others.
45
PRINCIPLE 33
Help others
with code
5. https://www.csc.gov.sg/articles/how-to-build-good-software
46
Always code as if the guy who ends up maintaining your code will be a violent
psychopath who knows where you live.
— JOHN WOODS
47
PRINCIPLE 34
Always implement things when you actually need them, never when
you foresee that you need them. If it is a “nice to have” then you
probably don’t actually need it.
6. https://ronjeffries.com/xprog/articles/practices/pracnotneed/
48
One of my most productive days was throwing away 1000 lines of code.
— KEN THOMPSON
49
PRINCIPLE 35
Don’t complain
No matter how menial the task, how frustrating the client is, or how
disorganized you think a process is, complaining doesn’t accomplish
anything. You are hired to solve problems, not to complain. It’s easy to
complain to sound smart and appear you are above it all. It’s a lot
harder to work with what you are given and do your best work. If you
are going to discuss an issue, always have at least one solution to
propose. You’re not always going to work on the most interesting tasks
but you can shine by working within the constraints that are given to
you.
50
PRINCIPLE 36
51
PRIN CIPLE 37
There are a lot of free resources online on any topic you want. But
the fact of the matter is, paid forms of education is usually higher
quality. Most importantly, when you pay for something, you are more
incentivized to follow through with finishing it. Education is the best
investment you can make. Save money by not buying a cup of coffee,
but don’t skimp out on a good education.
52
PRINCIPLE 38
Be willing to
change
53
You can’t predict, you can prepare.
— HOWARD MARKS
54
PRINCIPLE 39
Beware of
Attribution Bias
55
PRINCIPLE 40
56
Quit when you’ll be mediocre, when the returns aren’t worth the investment,
when you no longer think you’ll enjoy the ends. Stick when the dip is the
obstacle that creates scarcity, when you’re simply bridging the gap between
beginner’s luck and mastery.
— R YA N H O L I D AY
57
EPILOGUE
Final words of
advice
This whole journey is a marathon and not a sprint. If you enjoy every
single day and the work that you are doing, you are more likely to
flourish and keep doing what you are doing 10 years from now. The
best thing you can do for your career is to make sure that you enjoy this
learning process, you enjoy your work environment, and you do
everything in your power to maintain that happiness.
If there is one thing you should have taken away from this book, it is
that being a great programmer requires more than just technical
knowledge. Learn to communicate. Be someone that people love
working with. The more other people want to work with you, is a direct
indication of how successful you will be in your career as a
programmer.
If you need to take breaks, take breaks. If you need to quit because of a
toxic boss or manager, then leave. Do not compromise on your
58
happiness. Those who enjoy their journey are those who will be
rewarded in the future because they continue on their path to mastery.
Spend time away from programming. Enjoy your friends, family and life.
Programming isn’t everything. You don’t need to be sprinting and
learning every single moment of your life. Enjoy the process and enjoy
a good balance.
59
Find out more about my work and the classes I teach at:
W W W . Z E R O T O M A S T E R Y. I O
60