Effective Strategies For Learning How To Code

Written by: Reinder de Vries, April 5 2017, in App Development

Effective Strategies For Learning How To Code

Learning how to code is easy to begin with, but hard to master. Where do you start? How do you remember what you’ve learned? Why should you learn it at all?

In this article you’ll dive into several strategies that help you to learn how to code. The motivation from writing this article comes from several questions I’ve received in the past few weeks. Many aspiring app developers find themselves stuck.

One of those questions is this one:

“I feel a little overwhelmed by the vast amount of libraries and tools in Xcode. Going through your Add1 tutorials I just had to accept that I wouldn’t understand it all, though I believe I understood most of it. But it seems to me the syntax is quite complicated, at least for someone with a lot of python experience and little knowledge of C-based languages. Did you learn it as you went on?”

Let’s get started!

Getting Started with Learning How to Code

If you’re absolutely new to app development, then getting started is your biggest challenge. (If you’ve started already, move on to the next section.)

Typical questions you ask yourself are:

  • Where should I start?
  • What am I supposed to know?
  • Why am I even learning this?

Let’s start with motivation. Why do you want to learn how to develop your own apps? It’s a question only you can answer…

A few good reasons:

  • You want to improve your skills as a developer, and learn a new platform, for instance if you’ve worked with JavaScript or Ruby on Rails before
  • You want to bring one of your app ideas to life, so learning to code is a logical first step
  • You want to generate an income from the App Store as an indie app developer by publishing your own apps

It’s critical for success to have an “end goal” in mind, because it helps to focus your attention on the topics that matter. It’s also important to have some kind of a reward in mind, like making money, getting a raise, or just having a sought-after skill under your belt.

If you want to realize an app idea you have, you’ll just want to learn Swift and iOS development. If you want to make money in the App Store, you’ll have to learn App Store Optimization and App Marketing too. If you want to improve your skill as a developer, you might just only need to learn Swift programming.

Think about what Qui-Gon Jinn (Star Wars) says to young Anakin Skywalker: “Your focus determines your reality.” Determine your focus by asking why you want to achieve this end goal, and what you need learn almost automatically follows.

Are you still figuring out if iOS app development is the right thing for you? Try out some of the free coding guides here on LearnAppMaking.com.

OK… what then?

Get 5 of my best practices

Get 5 of my best practices

Learn how to build better iOS apps

I’ll show you exactly how I built a dozen professional iOS apps,
write extensible Swift code, and turn coffee into code.
Wait, what? Yup – into Swift code.

Got Started? Stick With It!

When you’ve decided you want to learn to code, stick with it! Continuing is as important as getting started, but there’s no point in having started if you won’t carry on.

When learning to code you’re almost guaranteed a level of discomfort, frustration and self-doubt. Don’t quit when the going gets tougher, because you’ll only reinforce the habit of giving up early.

If you struggle to keep your motivation, revisit your “Why” from the previous section. Is your original motivation as rock-solid as you think it is?

I recently got this question from a reader:

My biggest challenge is learning to code. I got enough app ideas. I am getting better but when I start to learn Swift I always seem to come to a point where I realize there is something else I should know before I can continue.

Continuing to learning how to code, i.e. the steps that follow after the first step, is all about discovery and filtering.

Strategy: Discovery and Filtering

Imagine a topic like “programming” as a red thread. Whenever you pull on the thread, a whole lot of threads come with it: variables, functions, languages.

Learning is like following these threads, pulling on the right ones until you reach your end goal. How do you know which threads to pull? That’s where discovery and filtering come in.

It’s pretty simple:

  • Discovery means finding any thread you can pull – any topic you can learn about
  • Filtering means deciding whether this topic is relevant or not

The paradoxical problem here is: “How do you know what’s relevant?” The only way is to dive in, to learn, and to decide if it’s relevant or not once you’ve gained a fair understanding.

A course, guide or textbook can help you discover and filter. In many cases, the author has done the work of discovery and filtering for you, and hopefully helps you with learning techniques and strategies. You can of course learn coding on your own, too!

Strategy: Googloogling

My most effective method for discovery is incredibly simple: Google a question, and start reading the first 5 pages that show up. Once you’ve read the 5 pages, you refine the question and Google it again. I call it “Googloogling”, because you don’t just Google once…

Here’s an example, about coding what happens when you tap a UIButton:

  1. Google “How to change a button with code?” and you learn you need to be more specific, i.e. type “iOS” and “UIButton”
  2. “ios change uibutton with code” and you learn that whatever happens after you tap a button is called an action.
  3. “ios uibutton set action” and you find the answer in 2 of the 5 first results, and the other 3 results mention similar methods.

This last step is important, because it forces you to reassess your question.

Your first take on a question isn’t always optimal. When you rephrase your question, you gradually move towards the answer. With the right question, the answer is almost always behind the first link on the search results page.

This discover-and-filter techniques creates “hooks” in your mind that you can “attach” other knowledge onto.

It’s similar to the well-known scanning-and-skimming technique, in which you glance over a textbook text to get a feeling for the topics in it. When you come across something you already know, you can literally attach what you don’t know to what you already know!

And… then your learning progress grinds to a halt.

Build better iOS apps by mastering best practices and app architecture » Find out how

You’re Lost and Don’t Know How to Continue

I think, with learning anything, there always comes a point where you’re lost and don’t know how to continue. Your wheels are spinning, but you’re not gaining any traction.

This is a very telling question I recently got from a reader of the blog:

My issue is that i get about halfway into these courses and hit a wall with my learning development. I start to feel a disconnect with understanding why i’m typing the code i’m being told to write (as in i’m not understanding the foundation of the code yet) then the self doubt creeps in that i’ll never understand the language.

This is where a good learning strategy comes in. You need to reset your focus, switch gears, and start moving forward again.

Let’s take a look at these strategies:

  • Avoiding copy-and-pasting code samples
  • Casually reading Apple’s documentation
  • Understanding the flow of code
  • Pause-and-recall and Spaced Repetition

You’ve looked at a good discover-and-filter strategy in the previous section.

Avoid Copy-and-Pasting Code Samples

Let’s look at a scenario. Say, you’re learning how to code and you’re following along with a code guide or tutorial.

The tutorial explains you what you need to do, and hopefully why as well. You’re asked to add a new function to a particular class, like this one:

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])  
{
    if let newLocation = locations.last  
    {
        print(newLocation)  
    }
}

And snap!, this is what you do:

  1. You select all the code in the guide
  2. You hit Cmd + C and switch over to Xcode
  3. You find the right spot in your code and hit Cmd + V
  4. PROFIT!

You’ve just copied-and-pasted code. This is wrong.

In a previous blog post I explained why it’s wrong to copy-and-paste code samples. It’s like learning how to craft furniture by only assembling prefab IKEA furniture…

When you’re starting out with a tutorial or course it’s OK for a while, but you miss out on a great deal of learning opportunities if you keep copy-and-pasting all your code!

Casually Reading Apple’s Documentation (Fun!)

Casual reading a technical document, for fun? You must be crazy…

It works, however! Apple has excellent documentation on many parts of Xcode, iOS, Cocoa Touch and Swift. Any framework or library has documentation on how to use it, and comes with a ton of example projects.

Apple’s documentation has had a bad rap for being long-winded, complex and poorly organized, but… that’s exactly what you need at this point.

Don’t forget: discover and filter. You’re not looking for a ready-made answer, but instead, you’re attempting to discover things you don’t know. The more you learn, the better you get at filtering, and the better you can navigate the red threads of learning!

It’s important to set the right expectations. When learning something new, you’re bound to encounter things you don’t know. That may sound like stating the obvious, but why would you then get disheartened and experience self-doubt by the things you don’t know?

Perhaps it’s the frequency. You’ve been learning a while now, but you keep running into things you don’t know. The encounters seem to increase in frequency, so you’re starting to think: “Maybe I’m missing something?”

This is more of a signal to take a step back and backtrack, than it is a good reason for self-doubt, a loss of motivation, and quitting. When you find something you don’t know, which you think you should know, then try to understand it. Pull on the red thread! If you don’t understand it, “Google back”. Go one step back down the Google ladder, and try to understand the topic at that level.

In a previous example you looked at setting the action on a UIButton. If you don’t know what a UIButton is, and you don’t understand why you’d need an “action” for it, backtrack to understand what a UIButton is first. Backtrack to tap gestures, backtrack to understand iOS, backtrack to understand the UIKit library, and so on.

When you get stuck, move backwards, and don’t pull the red threads tighter into a knot.

Grasping the “Flow” of Your Code

About 15 years back, as a teenager, I tried to learn how to play the saxophone. I ultimately failed, because I didn’t practice enough to get better, but I got away with one learning technique I still use today.

Try to sing your code…

When I had to master a new music piece, we’d always go over it singing the notes instead of playing them. Ta-da-da-di-da-da-da.

I could learn the music without having to bother with the techniques of the instruments, or where to put my hands, or how to control my breathing. My teacher would disconnect all those aspects of mastery, so that I could learn them one by one.

You can do the same with learning how to code. You don’t have to sing your code, but what about just reading the flow of the code? Next time you work with one of those tutorials, download the project first, and then see if you can figure out the flow of the code.

Do this:

  • Find the line of code that’s executed first, and figure out what happens next
  • Find event handlers in the code – what happens when the user taps, or inputs text, and then what happens next?
  • Find the navigational cues in the code – what happens when you tap a table view cell, and another view controller shows on screen?

You should be able to at least find one of these three flows. The easiest is finding the “main” flow, i.e. from app start to finish. The code either starts in AppDelegate, in the method application(_:didFinishLaunchingWithOptions:), or in the first view controller of the main Storyboard.

Step over all the lines of code, and go into any functions or methods of the project. An example:

  • The app starts and calls application(_:didFinishLaunchingWithOptions:)
  • That method sets up a view controller
  • The method viewDidLoad() of that view controller is called
  • That method then creates a UIButton
  • That view controller also includes an action called onButtonTapped(_:), that’s executed when the button is tapped
  • When the button is tapped, a new view controller is pushed onto the screen

Pause-and-Recall and Spaced Repetition

In the book A Mind For Numbers by Barbara Oakley, I read about two effective methods for learning science topics, like math. Learning to code is very similar to learning math, so you can use these strategies for learning how to code too.

Pause and Recall
When you’re learning something new, and you want to assess whether you understand it, do so by repeating the topic out loud with a closed book or page.

It’s easy to think “Oh, I understand this” when glancing over the topics, asserting that you understand it because it seems recognizable. Yes, you’ve seen it before, but that doesn’t mean you understand it!

This strategy works best for factual information or factual steps. Let’s get back to that UIButton and action example from the previous section. If you want to know whether you understand how to connect an action to a button, close your eyes and repeat the steps to connect an action to a button in your head.

  1. Create the button in Interface Builder
  2. Write a function with Swift and prefix it with @IBAction
  3. Go back to the button in Interface Builder, and open the Connections tab for the button
  4. Drag from the Touch Up Inside outlet to the File’s Owner, and select the function you coded earlier

Finally, check your work by doing it: did you visualize it the right way?

When you visualize the steps, you have to come up with them on your own. Instead of recognizing, you have to fabricate them, reinforcing those neural pathways in your mind. At the same time you boost confidence and motivation, because you’ve proven to yourself that you understand this topic.

Spaced Repetition
The second learning strategy is Spaced Repetition. There are a few dozen ways to apply this technique, but it’s easiest if you do it like this:

  • On Monday you’ve learned how to declare and initialize variables, a programming topic
  • The next Wednesday you want to learn about variable types, but before you start, you get back to what you learned on Monday. You repeat it with a closed book (see previous technique) and redo some coding exercises. Then, you learn about variable types
  • The next Friday you repeat what you’ve learned about variable types on Wednesday, and also briefly repeat what you learned about declaration and initialization on Monday. Then, you move on to the next topic.

Spaced Repetition literally repeats a topic over a set period, like a few days. Instead of constantly moving on to the next topic, you backtrack and repeat what you’ve learned.

This technique has been widely researched, and although it’s often used for smaller pieces of knowledge, like words in learning languages, the same principle applies to larger topics too.

Conclusion

Let’s take that advice to heart, and reiterate what you’ve learned in this article:

  • Before you start, have an end goal in mind. Why do you want to learn to code?
  • When you’ve started, don’t stop. Persistence is key in learning, and the more momentum you build up, the easier it gets to keep going.
  • Learning is about discovery and filtering. Don’t get disheartened when you get stuck on things you don’t know, and instead backtrack.
  • Switch gears when you feel your progress is stalling by applying a new learning strategy.
  • Avoid copy-and-pasting your code and instead gradually move to writing more code on your own.
  • Casually read Apple’s documentation, and use the Google technique to discover hooks you can attach new knowledge.
  • See if you can understand the flow of a particular piece of code, or a code project, and track the lines of code throughout the project
  • Use pause-and-recall to assess whether you understand a topic, and use Spaced Repetition to reinforce your comprehension and memory recall

Thanks for reading, and good luck!

Reinder de Vries

Reinder de Vries is a professional iOS developer. He teaches app developers how to build their own apps at LearnAppMaking.com. Since 2009 he has developed a few dozen apps for iOS, worked for global brands and lead development at several startups. When he’s not coding, he enjoys strong espresso and traveling.

Comments & Questions

Got a comment or question? Let me know! I read and respond to every one. Thanks!

  • Awesome, much appreciated John!

  • John

    I think I learned a very valuable lesson reading this. Thanks!