The Best Way to Learn is to BREAK Things
Tags: codenewbie, webdev, productivity, motivation
Published: 2020-03-03 03:21:34

I don’t know why we weren’t encouraged more as kids to color outside the lines. When I was growing up, everything had to be within the boundaries our parents and teachers gave us. Maybe times have changed (I’m not a father), maybe they haven’t – but working in the tech industry has made me realize this concept: <em>things don’t always work the way (you think) they should.</em>

Even more importantly, I think this is the best way to understand something: <em>BREAK it down, BREAK assumptions, and BREAK the rules.</em>

Now, as a software developer, this principle is foundational to my learning and how I write code (and honestly, I think this is a universal approach that can help you in all areas of life!)

Whenever I faced a problem, whether it be something as simple as a paper jam in a printer or something more complex like figuring out <a href="https://medium.com/better-programming/understanding-the-this-keyword-in-javascript-cb76d4c7c5e8">what ‘this’ is</a> in JavaScript, I use these three concepts to help me find a solution. Let me show you what I mean.        

<h3><strong>BREAK IT DOWN:</strong></h3>
In this first step, take some time to pause and consider everything, and I mean everything, that could be blocking you from getting to your goal.

Paper jam? Well, yes there is obviously a paper jam in the printer because the error says so. But you’d be surprised, that isn’t always the case.

What do we know for sure? <strong>I don’t have the page I printed in my hand.</strong>

1.    Is the printer on? <em>Yes.</em>
2.    Is there enough paper in the tray? <em>Yes.</em>
3.    Did I see the error myself or did someone tell me about the error from the other room? <em>For now, let’s assume I saw it myself (there’s a big difference by the way, more on this later). </em>
4.    Do I see a stuck paper when I open the printer? <em>Yes.</em>
5.    Did removing the paper fix the problem after I closed it back up? <em>Yes.</em>
6.    Can I print another page without running into the same problem? <em>Yes.</em>

OK – now we know it works! Sweet! But I had to ask myself at least 5 questions before I got to my expected result. It’s not always as simple as fixing the immediate problem. If I said no to any of the questions above, I could have gone about solving this problem a completely different way!

Coding can be approached in the same way. One of the things we are learning right now is <em>how to read code</em>. Learning to parse code like the V8 engine for JavaScript is ultimately key to ensuring you understand what the code is actually doing. Using the right terminology will help in the long run because you can BREAK down what is happening as your code is executed line by line. Here’s an example:

<code>console.log('Number 5:', 5);</code>

When I break it down, I’d read this line like this:

<blockquote>“The string ‘Number 5:’ and the number 5 are being passed as arguments into the log method of the console object”</blockquote>
<em>*Note: JavaScript generally executes from right to left</em>

Why not just say “console.log number 5 and 5”? Even though its might be an extreme example, imagine parsing through a Class with methods that have multiple conditionals, callback functions built using a library you just picked up – it can be easy to get lost in code, so breaking it down one element at a time can help slow you down and really see what is happening.

Furthermore, the dev tools are great for this with breakpoints! You can pause the code on each line and read it as you go to make sure you are on the right track logically. If you get an unexpected result… it’s time to BREAK assumptions!

<h3><strong>BREAK ASSUMPTIONS</strong></h3>
What do I mean by this? The truth is, we all see problems differently. We bring our own experience, knowledge and intuition with us when we attempt to problem solve. This is NOT necessarily a bad thing… but it is <em>crucial</em> to be aware of this as you address problems.

When I was a working in desktop support, I had a coworker who had a sticker on his monitor with the phrase “Users Lie” strung across it - reminding himself that people don’t always tell you the truth when something doesn’t work. Harsh.

I think a better way to think about it is this: <em>“people (including me!) don’t always know how to ask a question or how to explain their problem.”</em>

Don’t assume you know all the variables to a problem. Don’t assume all involved parties see things the way you do. We all have different levels of technical literacy – a broken computer monitor might just mean the cable was loose, not actually broken. Maybe you misspelled a variable name you were referencing or there’s a syntax error in your code. Maybe you weren’t explaining your problem to someone as clearly as you thought you were.

In my example about code reading above, think about this:

<em>Code reading line by line helps you understand what is a variable, what is an object, what is a function, method, etc. as you read it. It’s easy to make assumptions when you are first starting out. Using the wrong vocabulary when you explain your problem to another developer can make it harder for them to see your thought process or identify the issue at hand.</em>

It’s important to consider how you’d fix something, try it, read documentation, google it, ask for help, ask to re-contextualize the scenario, ask for clarification, just a lot of questions!

Lastly…

<h3><strong>BREAK THE RULES</strong></h3>
I think the best programmers are the ones that try to break their code while they build it. At the very least, those who have the curiosity to try and break things will learn quicker and why certain conventions are adopted over others.

There is always more than one way to skin a cat. When I get my code in a functional state, I try to figure out ways to refactor and/or test arguments that my function might not be anticipating. If someone using my page types something in a form incorrectly, will my code account for that?

If I’m code drilling as practice, I try to solve the problem on my own and once I do, I always check to see how others did it if that’s an option. Learning to see how others think and attack the same problem you faced can help with your development journey.

Once you found your answer, don’t settle right away! Give yourself some time to see if you can improve your answer or find better ways of doing things. Use whatever tools you have at your disposal to deepen your understanding and comprehension. At the end of the day, keep coding every day and you will become a better developer!