Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
10 tips to save you time and frustration while programming
1. 10 TIPS TO SAVE YOU TIME
AND FRUSTRATION WHILE
PROGRAMMING
BY: JEFF HALE
2. PROGRAMMING CAN BE FRUSTRATING
2
Many false starts are due in part to the slow and tedious process of learning
to code and the frustration that accompanies it. Consequently, I’m passionate
about removing the unnecessary obstacles that prevent people from becoming
competent coders. There will always be obstacles, but there’s no reason for
unnecessary obstacles.
Here are 10 tips to help you more quickly leap over the hurdles and achieve a
sense of competency. Many of these tips might seem minor or obvious to you
if you’ve been coding for years, but when starting out, nothing is obvious. And
even if you’ve been coding since cell phones were called car phones, there
might be a tip or two that will save you time.
3. 1 +
3
Most of the time when you are learning to code, I suggest you split your screen(s) into
two side by side panels — one for the code you’re working on in your Jupyter notebook
or code editor and one for your web browser. You’ll use your web browser to look at
documentation, Stack Overflow, and tutorials. If your screen is too small, I suggest you
get a bigger one — if you can afford it. You can get a 25-inch monitor on Amazon for a
little over $100 in the US. As you get more proficient, you’ll often want to focus on a
single piece of work. Use can use keyboard shortcut keys to toggle between split screen
to full screen.
SPLIT YOUR SCREEN
For a Mac, I like the BetterSnapTool for $2.99.
Some Windows options are discussed in this article.
4. 4
CUT OUT
DISTRACTIONS
Silence notifications on your
computer and phone. Move your
phone away from you if you can.
Play some calming instrumental
music or use noise-canceling
headphones if you’re in a noisy
area. The better you can focus,
the faster you can learn.
2
TYPE OUT
EXAMPLE CODE
You can’t just read a tutorial and
hope to remember it. Copying and
pasting is of little value. You have
to type it. Then extend it. Then
type it from memory. “In theory,
there’s no difference between
theory and practice. In practice,
there is.” — Benjamin Brewster
3
LEARN OVER
MULTIPLE DAYS
Learn a new code concept and
quiz yourself on it over multiple
days. Research shows that when it
comes to remembering things for
the long haul, spaced repetition
works far better than cramming.
4
5. 5
LEARN BY TEACHING
Clearly explaining a concept to
others — either out loud or in writing —
forces you to understand the
concept’s essence, draw relationships, and
create analogies. You strengthen the
connections in your brain. This tip is part of
the excellent Feynman learning technique.
5
6. 6
Variable types aren’t the most exciting topic. Classes
with attributes and methods might seem advanced.
But once you understand a language really well,
the library is far easier to use. You’ll only make a
few errors and save so much time.
UNDERSTAND A PROGRAMMINGUNDERSTAND A PROGRAMMING
LANGUAGE WELL BEFORE YOU TRYLANGUAGE WELL BEFORE YOU TRY
TO USE A LIBRARY WRITTEN IN IT.TO USE A LIBRARY WRITTEN IN IT.
LANGUAGE BEFORE THE LIBRARY
6
7. 7
One Tab is a handy Chrome
extension to use to save tabs
for later.
7
LEARN ONE THING AT A TIME
Don’t try to learn two things at once. You
don’t learn twice as slowly, you learn like
10x as slowly. Relatedly, don’t get
distracted by shiny things. Have a place
to keep URLs that look like tempting rab-
bit holes to jump down. Put the URLs that
aren’t relevant for the thing you’re learning
right now somewhere for safekeeping.
8. 8
SLEEP, EXERCISE,
AND STAY RESILIENT
Put your brain in a strong
position to form and strengthen
neural connections. Learn more
about techniques to help you stay
sharp in my Memorable Python
book.
8
LEARN TO TYPE
CODE FASTER
The more you type unusual symbols,
the faster you become at typing them.
However, a little intentionality can speed
this process significantly. Invest in learning
a good touch typing form. Here’s a little
exercise to help from SpeedCoder.
9
9. 10
9
BECOME A PRO WITH KEYBOARD SHORTCUTS
HERE
are links to shortcuts
for:
Chrome
Mac
Windows.
Then restart your terminal and type two
keystrokes instead of two words.
IF
you’re a data scientist
or data analyst, I made a
GitHub Gist of Jupyter
Lab shortcuts here.
IT'S
also a good idea to create
shortcuts for a Mac or Linux
terminal by adding lines such as
the following to your Bash Profile
at:
~/.bash_profile:alias gs="git status".
10. +
10
Here's a game plan for resolving
95% of errors quickly.
1. Look for a typo
2. Read the top and bottom of the error
message stack trace first
A parentheses that are missing or a variable or function that’s misspelled. Syntax highlighting can help here.
Always do your typing in software that provides code highlighting to improving your chances of avoiding or
quickly fixing indentation, unbalanced parentheses, and similar errors. There are lots of good code editors to
choose from. If you are just starting out, I suggest VSCode — it has the most market share, it’s free, and it
has gobs of handy features.
The code in the middle is generally less helpful. Then look at your code and see if you can figure out what’s
wrong, given the clues in the error message. If you can’t decode the error message quickly, copy and paste
the last line of the message into Google (if using Python. Other languages might have the error message
before the stack trace). New coders biggest mistake is not turning to google with an error message quickly
enough.
BONUS
11. +
11
...
3. Filter the online resources
Separate the wheat from the chaff. Here are a few heuristics to help you find higher quality resources faster:
Stack Overflow, Medium, Reddit, Hacker News, Dev and other online communities have feedback indicators such as
upvotes or claps to show which content is on target. These metrics aren’t perfect, but they generally work pretty well.
Stack Overflow, the Towards Data Science Medium publication, GitHub issues for the repo in question, the official
docs for a language or library are the sites where I find the most solutions.
It’s hit or miss with the quality of blogs in Google search results. If you’re using Python, I can suggest some good sites
based on my experience:
Real Python
Data School
Dataquest Blog
DataCamp Blog
Practical Business Python
Chris Albon
12. +
12
...
4. Avoid older resources
For most problems, you want resources that aren’t more than a few years old. When searching for a solution to an
error on Google, filter out old results — either by time-boxing the search parameters or informally when looking over
the resulting snippets. If you’re starting out in Python, content about Python 2 from 2009 is unlikely to help you.
APIs evolve and how things were done is often not the recommended way to do them today. You are more likely to
find an applicable answer in relatively recent results. If your initial forays are unsuccessful, then it’s worth looking
through older posts and lower-quality sites on the next pass.
5. Learn what error codes mean
Here’s a list of common error codes and explanations for Python. And here’s a really nice flow chart to help you tackle
common Python errors. If you use the Python pandas library for data manipulation, there are common errors. Here’s
a GitHub Gist I made with a Jupyter notebook of common errors and how to resolve them:
Common pandas errors: https://gist.github.com/discdiver/2f8df1c3f1c66f47129568a82c0666e5.
13. TO SUM IT UP...
13
Hopefully, these 10 tips for reducing frustration and increasing your speed will
save you time. And hopefully, the 5-step plan for resolving error messages will
help you or someone you learn more faster.
With the right mindset, a little guidance, and a lot of practice anyone can learn
to code. It might not be fast or easy, but hopefully, this article will make it a bit
less frustrating. Happy Learning!
If you’re interested in tips to help you increase your productivity, subscribe to
the author’s monthly Data Awesome newsletter.
Original post here.