Docsity

Code and Drawing Instructions, Cheat Sheet of Computer science

Partial preview of the text

Download Code and Drawing Instructions and more Cheat Sheet Computer science in PDF only on Docsity!

LEARN TO

CODE

Ǹǹ Rules to

Learn to Code

Dr. Angela Yu

iOS, WatchOS and Web Developer

Lead Instructor at The App Brewery

www.appbrewery.co

Trick Your Brain with the ǹǷmin Rule

Learning to code is a bit like going to the gym. Even if you max out and
spent a whole weekend at the gym, you will not see a visible difference in
your body. The more regularly you learn to code, the more likely it is that
you’ll start seeing your ripped coding muscles. (The irony is not lost on
me).
But the problem is where do you find the time? Between working your
full-time job, spending time with your family and life admin, when are you
supposed to sit down and practice this “daily coding”?
While I was working as a doctor, I spent about 12 hours at the hospital,
1-hour commuting and approximately 2 hours on general life-sustaining
stuff, such as eating. So that left me with only 9 hours remaining in my day.
Theoretically, 2 hours could be allocated to coding practice and 7 hours on
sleep. But there is nothing more difficult than trying to convince your
work-saturated brain to sit down and learn when you could be watching
Game of Thrones with a tub of ice-cream.
But then I found a trick.
As humans, we have a lot of inertia. This can be bad for us - I’m looking at
you, “24” box set. However, we can also turn it to our advantage. I found

All rights reserved © The App Brewery www.appbrewery.co

that once I got started coding and making things, I got so absorbed into the
project, that I no longer cared about TV, food or sleep. There were quite a
few weekends when I coded until sunrise.
So how do we take advantage of this inertia? First, you must understand
that task-switching is very difficult. It requires a lot of motivation. If as soon
as you get home, you slump on the sofa and switch on the TV, you’ve
already lost that evening. This is because the amount of motivation required
to task-switch and do something not driven by evolution like eating or
sleeping is a Herculean task.
This is why the moment you enter the door and change to a new
environment is the most crucial moment. If at this moment, you tell yourself
that you are just going to do 20 minutes of coding practice, you will most
likely succeed and use your own inertia to end up learning for an hour or
more. No brain will perceive a 20-minute task as a lot of effort and you end
up tricking your brain to take advantage of your evening.
The next step is to develop a habit. Research suggests that in order to
develop a new habit, you have to carry out the task daily for a month. I’ve
used this next trick for loads of different things, from exercising to coding, it
invariably works like a charm. To preface this trick, I want you to imagine a
wall with five paintings hanging on it, four of which are perfectly aligned,
perfectly horizontal, but one is crooked. Now really imagine it, is there a part
of you that wants to fix it?
Now let’s imagine a monthly calendar with boxes representing individual
days. If you nurtured that new habit on a particular day, then you make a
line through that day. If you continued your streak the next day then you
extend that line and so on and so forth. There is something about not
breaking a continuous line that motivates most people to continue to

All rights reserved © The App Brewery www.appbrewery.co

Code for a Purpose

When I first started learning how to code, there were countless times when I
picked it up then gave up, again and again. This is a common story amongst
self-taught coders. Looking back, after teaching so many students, I finally
realise what’s going on. A lot of beginners start learning to code by picking
an arbitrary language and follow along with a bunch of tutorials. Copying
code, line by line, sometimes writing code to work out prime numbers, other
times to find all the even numbers. But you know what? I can find prime
numbers a lot faster by Googling for it and picking out even numbers is
really not all that interesting.
Here’s the truth. If you are learning to code for the sake of learning to code,
it’ll be pretty difficult for you to get good at it. Skills that require a lot of
time to hone, like programming, will eat into your pool of internal
motivation. Something from within that makes you forget to eat and sleep. I
can honestly say that coding on my own projects is one of the most
enjoyable things I do. It combines logical thinking with creativity, and at the
end, you will have made something. In most cases, something that the
world has never seen. Something that could make your life easier or more
enjoyable. Something that could make loads of people's lives easier and
more enjoyable. It’s like making a crazy-beautiful custom motorbike in your
garage, without needing the garage or spending a cent on the components.
This is what motivates most people. The creating part. The making part. So I
urge you to start learning to code by following a tutorial that makes

All rights reserved © The App Brewery www.appbrewery.co

something, anything. Of course, it’s unlikely that at the beginning you’ll be
able to code up Clash of Clans or League of Legends. But you’ll be able to
make something interesting. It could be a dice game or a flash-card app. But
as long at the end of the tutorial, you’ll have made something you can use
and play with, then you’ll be far more motivated to code to the end.
During all our courses, we always tell our students to think up of a simple
app that they want to make. Something that uses the skills that they’ve
learnt during the course but will also stretch them a little because they have
to find out how to include some new functionality.
We had a student who went on to make an app that wakes them up a
minute earlier every day to ease the transition to an earlier waking time.
There’s a student who made a custom slideshow app as a mother’s day
present. Someone else made an app that is a timer for making perfect
steaks based on its weight and thickness.
There are no limits on your imagination. It will be difficult when you start
working on your own app because there are no step-by-step instructions,
but it will also bring about the biggest improvement in your coding ability.

All rights reserved © The App Brewery www.appbrewery.co

shirt-ripping mammal that comes out during a full moon, it’s just spelt
differently.
Printing to the console in Swift:
print(“Hello Werewolves”)
Printing to the console in Java:
println(“Hello Werwölfe”)
So, decide on the task that you are trying to accomplish, then pick the best
tool for that task.

All rights reserved © The App Brewery www.appbrewery.co

Understand What You’re Writing

I have an issue with the way that most programming tutorials are written.
There are far too many tutorials where you see the “this is how you draw an
owl” phenomenon.

All rights reserved © The App Brewery www.appbrewery.co

The key to learning to code is all about ramping. You want to be stretched
over and over again and for knowledge to be built on previous knowledge. If
that ramp is too steep, you’ll get lost. If that ramp is too shallow, you’ll get
bored. The right gradient is different for everyone. That’s why we encourage
students to use the speed change functionality liberally on our tutorials. This
way, you can listen at double speed if you’re comfortable with the concepts
and slow down to half speed if it’s something unfamiliar and you need time
to understand and absorb.

All rights reserved © The App Brewery www.appbrewery.co

Ǽ It’s Ok to Not Know

Software engineers are purportedly the profession that has the largest
population of Imposter Syndrome sufferers. Imposter Syndrome is a
psychological phenomenon where people feel like frauds and massively
underestimate their own skills and abilities.
Programmers tend to be self-critical and constantly feel that everyone else is
better at programming than they. If you’ve ever felt this way, you’re not
alone, as studies show that a massive 70 percent of people have imposter
syndrome.

All rights reserved © The App Brewery www.appbrewery.co

for us. For example, the code for recording sound is only a short search
away, why would you need to memorise it?
The skill that most employers look for when recruiting is the ability to think.
Knowledge is valued in a world where information is hard to come by. In the
1800s, only the rich had access to good books and good teachers. Now,
everyone has all the information they had and more at the tap of a mouse.
Information is losing value, the ability to think is the stock to buy. So don’t
be afraid to search, to ask on StackOverflow or to find resources to help you
solve your issues. The best programmers do it.
The skill you need to hone is in asking good questions and understanding the
answer. There is no point copy-pasting code from a StackOverflow answer if
you have no clue how it works. Because StackOverflow works on a
reputation system, it’s in their interest to be as clear as possible in their
answer in order to be marked as correct and collect upvotes.
In most cases, it doesn’t make sense to start searching StackOverflow
whenever you get stuck. The first option should always be trying to figure it
out yourself. So your program doesn’t do what you expected it to, but before
I typed the last 3 lines of code, it was working fine. So let’s figure out what
in those last 3 lines broke my app?
If you really can’t figure it out, start with Google. Search for your query or if
you have a bug paste the error codes and the error message. Chances are
that as a beginner, your programming woes will be very common and
somebody might have even taken the time to write a clear and concise
tutorial to help you understand your bug. As you grow more skilled in
programming, the problems you’ll encounter get more and more obscure,
but hopefully, if you followed the other 11 rules, you will also be a more

All rights reserved © The App Brewery www.appbrewery.co

capable programmer and figure it out yourself or know exactly where to get
help.
The other reason why you should start with Google is that StackOverflow’s
search algorithm organises questions and answers by recency and not
popularity. A lot of the problems you will encounter while starting out will
have been asked and answered years ago but still massively popular.
So ask wisely and you will reap the benefits from the community. One day
when you yourself become a code master, you’ll be giving back to that same
community and helping the next generation of programmers.

All rights reserved © The App Brewery www.appbrewery.co

Be Accountable

Be accountable to someone. Show your work.
The biggest problem with online coding courses is the lack of accountability.
No doubt there are loads of great Massive Open Online Courses (MOOCs),
such as Coursera, Udacity, Udemy, Skillshare. But what are the
consequences of not doing your homework or missing a month’s worth of
lectures? Nothing. Nobody cares.
Let’s face it, internal motivation is not strong in any of us. We can always
find a reason why we deserve to “Netflix and chill”. I can’t even count how
many online courses I’ve signed up to and subsequently not listened to a
single lecture or completed a single piece of coursework.
You need accountability and commitment to learning. Think back to your
university days, would have bothered to finish that essay at 3 AM if nothing
depended on it? Would you have gone to any of the lectures if you didn’t
care about passing or failing?
This is why we try to introduce accountability into our courses. We’ve
realised that matching up students with a buddy helps. Someone else who is
a beginner, at the same level as you who sometimes helps you and other
times needs your help. Sometimes, as people’s learning rates diverge or if
you’re paired up with a lazy bugger, you can swap it up and get a new
buddy. Because this system is entirely voluntary, there a degree of
self-selection for people who work well in teams and are motivated by

All rights reserved © The App Brewery www.appbrewery.co

others. Just as you’re more likely to go to the gym if you sign up with your
partner, you’re more likely to learn if you have a coding buddy.
So if you’re not on our course then find your own. There’s plenty of
Facebook groups dedicated to those who are learning to code. There’s an
entire subreddit (r/learnprogramming) dedicated to this, I’m sure you’ll find
like-minded people somewhere online or offline.
The next thing I’m going to tell you will be controversial. We believe that
people don’t value things that don’t have a value. This is the reason why
Coursera is taking down a large number of their free courses. They saw that
millions of people were signing up for it but no one was taking any of the
classes let alone complete any of the projects. It was actually detrimental to
students’ learning to offer a free course. We all have a degree of hoarding
tendencies and it’s very easy to signup for a bunch of stuff that the
future-you can suffer through. There’s always tomorrow, she says.
So if you are driven more by external motivation than internal, try to use a
little bit of financial motivation to drive your learning. Think about how much
a life skill is worth to you and put your money where your intentions are.
See if you’re engaging with the course content more with or without the
financial commitment. There are plenty of places where you can pay
something affordable to motivate yourself to start a regular learning habit.
The final part of this rule is to try and find ways of getting assessed. Ok, so
getting assessed is right up there with death and taxes in terms of how
much people enjoy it. But when learning anything, it’s always important to
get feedback. You will get an objective assessment of your current skill level,
instead of feeling like an imposter or brimming with false confidence.
Coursera has a system where the students mark each other's’ work. At the
App Brewery, we use Github education to test your code and look for bugs

All rights reserved © The App Brewery www.appbrewery.co