Text Practice Mode
12 Rules To Learn Code (part III)
created Aug 11th 2020, 16:13 by MuathNasr
2
1764 words
1 completed
5
Rating visible after 3 or more votes
00:00
9- Play Foosball
When you see Hollywood movies about programmers, they're usually sat in front of a laptop, mashing the keyboard like they're in some sort of high-stakes "smash the mole" game.In a company, people tend to complain that the programmers are always playing foosball or doing something else that doesn’t look like work. People might not be able to tell, but they are in fact working. When you see them enjoying their foosball game, laughing and joking, they’re probably suffering inside. For there’s a bug, there’s always a bug. Or there’s something mysterious about their code that they can’t work out. Maybe the code is working perfectly, but unexpectedly (programmers don’t like anything unexpected by the way). Like if they just typed out a thousand lines in one go,and unexpectedly there are no errors.
Other people might not understand, but in these situations, it’s almost always worth stepping away from your code and giving it some time and distance. Do you have a bug in your code that you can’t work out? Sleep on it, play foosball, go for a walk. In 9 out of 10 cases, the solution will become apparent. In the remaining 1 out of 10 cases, you’re just screwed. This may sound unintuitive, but my advice is always to code less, think more. Once the poorly thought-out code is written and brought into the world, you’ll inevitably have to go back and comb through your code, line-by-line, refactoring and deleting things. This is always a painful experience. So remember, the easiest code to get rid of is the code that was never written.
10- Get a Mentor
When I was learning French, I came across a method that resulted in the greatest leap in my speaking abilities. That was having language exchanges over Skype. I would pair up with a native French speaker who wanted to learn English. We would spend half an hour speaking French and half an hour speaking English. We would both dedicate an hour each week to improving the language that we were trying to learn. While we were having a conversation in French, he would correct my pronunciation or grammar and suggest the ways that I could construct my sentences to sound more native. Pair programming is an agile software development technique that’s based on very similar principles. For example, a learner and a mentor would sit down at the same workstation and work on a problem. The learner is in charge of writing code and the mentor reviews the code line-by-line as they are written. It can be uncomfortable at first because it’s a bit embarrassing making mistakes and having them pointed out to you. But if you have a mentor who is a good teacher then they will offer you decades of accumulated wisdom that can lead to massive improvements in your own ability, all within a few hours. You’ll get to tap into someone who’s had the time to hone their skills, find efficient ways of doing things and show you how they program and approach problems. Good mentors don’t solve your problems, rather they practice the Socratic method of asking good questions that get you to think for yourself. If you ask me how to write a networking call, of course, I can simply type it all out and get you to copy it. But that doesn’t help you. Instead, if you show me how you approach the problem and I show you how I approach the problem then you can learn so much more than just following a recipe. The next time you encounter a different problem, you can apply the same approach and start solving it yourself. Always remember that information is cheap. A century ago, if I wanted to learn about the causes of disease, I probably had to be an aristocrat, or chop wood and carry water for a master and become their apprentice. Nowadays I can search Google and get my answer in a few seconds. So don’t get hung up on information. Learn to think instead. How to approach a problem. How to break down the problem. How to frame the problem. These skills will take you much further than simple memorisation and regurgitation. But where do you find a mentor? There are programming related Meetups happening in almost every city in the world. Go to www.meetup.com and find one related to a language you’re trying to learn. Attend the meetups, get to know people. Exchange your expertise for their expertise. Maybe someone needs an accountant, maybe someone needs legal advice. Exchange your time for their time. Don’t say to someone, “will you be my mentor?”. No one wants to throw away their free time for some stranger. Instead, offer your help in return for their help and you’ll be successful in finding a mentor 95% of the time.
11- Get into the Habit of Chunking
So you have an awesome app idea. But it’s way-way-way too complicated for your current skill level. What do you do? You join the Chunking Express.
Nope, I’m not talking about the art house movie. I’m talking about breaking down your programming problem.
Let’s say that you’re trying to make a robot that can butter toast. (If anyone is working on one of these I’d happily fund your Kickstarter!) The robot doesn't know anything about toast or butter or knives. Believe it or not, it actually takes pretty sophisticated circuitry in our brains to be able to achieve something as simple as buttering a slice of toast. (This is probably why I can’t seem to do it without coffee).
So creating a robot that does all of that autonomously is really complicated and difficult. But as we’re good programmers, we can do some chunking and break down the problem. The robot doesn’t really need to know what is toast and what is butter, we’re not making Skynet here, so let’s just stick to the practical things. There are three things we need the robot to do: 1. Pick up and arrange the piece of toast in the ideal buttering position. 2. Pick up a serving of butter. 3. Place butter on toast with decent coverage (this is the part I find most difficult). Next, you break each module down even further. In the process, you can think about alternate ways of solving the problem. For example, does the robot need to “spread” the butter? Or can it just melt the butter onto the toast? Does it need to learn to pick up a knife? Or can it have some sort of inbuilt knife-arm, like some sort of prison shiv pirate?
The more that you break down problems and define the issue that you’re trying to solve, the easier it is to package your code into bite-sized chunks. The simpler the chunk, the easier it is to tackle. So the next time that you’re trying to make that “cross between Snapchat and Evernote”, remember to break down the problem into solvable chunks.
12- Break someone else's code
One of the most important steps to take in order to make the jump from learner coder to a fully fledged programmer is understanding how to get help. Everyone needs help. Everyone, including those so-called “God Level Programmers”.
But what you do with the help will determine how fast you progress as a coder. On a site like StackOverflow, it can be very tempting to just copy and paste the code that someone has provided. Your program works exactly as you hoped it would and off you go on your merry programming ways. This exercise didn’t teach you anything other than code reliance. Because the next time you encounter the same problem but in a different situation, that same code snippet that someone provided may not work anymore. Then what do you do? You’re stuck. That’s why there’s a rule in programming that says “never copypaste code that you don’t understand”. So what should you do when you’re confronted with a block of code that solves your problem but you have no clue how it works? Break it down.
Step 1 - Copy and paste the code into your program. (yes, yes, I know I just said not to do that, patience, patience).
Step 2 - Make sure that your program or application is functioning as expected. I.e. confirm that block of code really did solve your problem. Step 3 - Delete the copy and pasted block of code line by line.
Step 4 - Each time you delete a line, check to see what’s been broken. Does the app still run? What are the error codes? What has deleting that line of code done to your program?
Step 5 - Even if you think you know what a line of code does, delete it anyway. The most important task as a programmer is to always test your assumptions against the outcome. For the most enjoyable feeling as a programmer is for the real world to validate your assumptions. You know how nice it is when your boyfriend/girlfriend/husband/wife says those magical three words?
It’s like that, but better.
Step 6 - Swap some of the lines around. Can the same functionality be achieved with a different order of lines? Why were they written in the order they were written in?
By breaking the solution code, line-by-line, you’ll learn and understand what each line does and why it’s been written. This is a far better way to use code from other people than just pasting it in and hoping for the best. Once you understand why each of those lines was necessary, the next time you encounter a similar problem, you’ll be able to tease out the problem and solve it yourself.
Once you’ve mastered breaking code from StackOverflow, the next resource to target is GitHub. It’s a tool used by programmers for collaboration but it is also one of the largest repositories of open source code.
So how can you use it to become a better programmer? Let’s say that you want to make an Instagram clone. But unfortunately, you don’t know how to do that. So you head over to github.com and search “Instagram” or “photo app”.
Inevitably, there will be something written in Swift/Objective-C/Java that you can download and take a look at.
Think about the structure of their program. Take a look at all the classes, the constants, the interplay. Make some modifications to the code. Does it still work or have you broken it? Why did you break it? Is there a link that you didn’t identify?
When you see Hollywood movies about programmers, they're usually sat in front of a laptop, mashing the keyboard like they're in some sort of high-stakes "smash the mole" game.In a company, people tend to complain that the programmers are always playing foosball or doing something else that doesn’t look like work. People might not be able to tell, but they are in fact working. When you see them enjoying their foosball game, laughing and joking, they’re probably suffering inside. For there’s a bug, there’s always a bug. Or there’s something mysterious about their code that they can’t work out. Maybe the code is working perfectly, but unexpectedly (programmers don’t like anything unexpected by the way). Like if they just typed out a thousand lines in one go,and unexpectedly there are no errors.
Other people might not understand, but in these situations, it’s almost always worth stepping away from your code and giving it some time and distance. Do you have a bug in your code that you can’t work out? Sleep on it, play foosball, go for a walk. In 9 out of 10 cases, the solution will become apparent. In the remaining 1 out of 10 cases, you’re just screwed. This may sound unintuitive, but my advice is always to code less, think more. Once the poorly thought-out code is written and brought into the world, you’ll inevitably have to go back and comb through your code, line-by-line, refactoring and deleting things. This is always a painful experience. So remember, the easiest code to get rid of is the code that was never written.
10- Get a Mentor
When I was learning French, I came across a method that resulted in the greatest leap in my speaking abilities. That was having language exchanges over Skype. I would pair up with a native French speaker who wanted to learn English. We would spend half an hour speaking French and half an hour speaking English. We would both dedicate an hour each week to improving the language that we were trying to learn. While we were having a conversation in French, he would correct my pronunciation or grammar and suggest the ways that I could construct my sentences to sound more native. Pair programming is an agile software development technique that’s based on very similar principles. For example, a learner and a mentor would sit down at the same workstation and work on a problem. The learner is in charge of writing code and the mentor reviews the code line-by-line as they are written. It can be uncomfortable at first because it’s a bit embarrassing making mistakes and having them pointed out to you. But if you have a mentor who is a good teacher then they will offer you decades of accumulated wisdom that can lead to massive improvements in your own ability, all within a few hours. You’ll get to tap into someone who’s had the time to hone their skills, find efficient ways of doing things and show you how they program and approach problems. Good mentors don’t solve your problems, rather they practice the Socratic method of asking good questions that get you to think for yourself. If you ask me how to write a networking call, of course, I can simply type it all out and get you to copy it. But that doesn’t help you. Instead, if you show me how you approach the problem and I show you how I approach the problem then you can learn so much more than just following a recipe. The next time you encounter a different problem, you can apply the same approach and start solving it yourself. Always remember that information is cheap. A century ago, if I wanted to learn about the causes of disease, I probably had to be an aristocrat, or chop wood and carry water for a master and become their apprentice. Nowadays I can search Google and get my answer in a few seconds. So don’t get hung up on information. Learn to think instead. How to approach a problem. How to break down the problem. How to frame the problem. These skills will take you much further than simple memorisation and regurgitation. But where do you find a mentor? There are programming related Meetups happening in almost every city in the world. Go to www.meetup.com and find one related to a language you’re trying to learn. Attend the meetups, get to know people. Exchange your expertise for their expertise. Maybe someone needs an accountant, maybe someone needs legal advice. Exchange your time for their time. Don’t say to someone, “will you be my mentor?”. No one wants to throw away their free time for some stranger. Instead, offer your help in return for their help and you’ll be successful in finding a mentor 95% of the time.
11- Get into the Habit of Chunking
So you have an awesome app idea. But it’s way-way-way too complicated for your current skill level. What do you do? You join the Chunking Express.
Nope, I’m not talking about the art house movie. I’m talking about breaking down your programming problem.
Let’s say that you’re trying to make a robot that can butter toast. (If anyone is working on one of these I’d happily fund your Kickstarter!) The robot doesn't know anything about toast or butter or knives. Believe it or not, it actually takes pretty sophisticated circuitry in our brains to be able to achieve something as simple as buttering a slice of toast. (This is probably why I can’t seem to do it without coffee).
So creating a robot that does all of that autonomously is really complicated and difficult. But as we’re good programmers, we can do some chunking and break down the problem. The robot doesn’t really need to know what is toast and what is butter, we’re not making Skynet here, so let’s just stick to the practical things. There are three things we need the robot to do: 1. Pick up and arrange the piece of toast in the ideal buttering position. 2. Pick up a serving of butter. 3. Place butter on toast with decent coverage (this is the part I find most difficult). Next, you break each module down even further. In the process, you can think about alternate ways of solving the problem. For example, does the robot need to “spread” the butter? Or can it just melt the butter onto the toast? Does it need to learn to pick up a knife? Or can it have some sort of inbuilt knife-arm, like some sort of prison shiv pirate?
The more that you break down problems and define the issue that you’re trying to solve, the easier it is to package your code into bite-sized chunks. The simpler the chunk, the easier it is to tackle. So the next time that you’re trying to make that “cross between Snapchat and Evernote”, remember to break down the problem into solvable chunks.
12- Break someone else's code
One of the most important steps to take in order to make the jump from learner coder to a fully fledged programmer is understanding how to get help. Everyone needs help. Everyone, including those so-called “God Level Programmers”.
But what you do with the help will determine how fast you progress as a coder. On a site like StackOverflow, it can be very tempting to just copy and paste the code that someone has provided. Your program works exactly as you hoped it would and off you go on your merry programming ways. This exercise didn’t teach you anything other than code reliance. Because the next time you encounter the same problem but in a different situation, that same code snippet that someone provided may not work anymore. Then what do you do? You’re stuck. That’s why there’s a rule in programming that says “never copypaste code that you don’t understand”. So what should you do when you’re confronted with a block of code that solves your problem but you have no clue how it works? Break it down.
Step 1 - Copy and paste the code into your program. (yes, yes, I know I just said not to do that, patience, patience).
Step 2 - Make sure that your program or application is functioning as expected. I.e. confirm that block of code really did solve your problem. Step 3 - Delete the copy and pasted block of code line by line.
Step 4 - Each time you delete a line, check to see what’s been broken. Does the app still run? What are the error codes? What has deleting that line of code done to your program?
Step 5 - Even if you think you know what a line of code does, delete it anyway. The most important task as a programmer is to always test your assumptions against the outcome. For the most enjoyable feeling as a programmer is for the real world to validate your assumptions. You know how nice it is when your boyfriend/girlfriend/husband/wife says those magical three words?
It’s like that, but better.
Step 6 - Swap some of the lines around. Can the same functionality be achieved with a different order of lines? Why were they written in the order they were written in?
By breaking the solution code, line-by-line, you’ll learn and understand what each line does and why it’s been written. This is a far better way to use code from other people than just pasting it in and hoping for the best. Once you understand why each of those lines was necessary, the next time you encounter a similar problem, you’ll be able to tease out the problem and solve it yourself.
Once you’ve mastered breaking code from StackOverflow, the next resource to target is GitHub. It’s a tool used by programmers for collaboration but it is also one of the largest repositories of open source code.
So how can you use it to become a better programmer? Let’s say that you want to make an Instagram clone. But unfortunately, you don’t know how to do that. So you head over to github.com and search “Instagram” or “photo app”.
Inevitably, there will be something written in Swift/Objective-C/Java that you can download and take a look at.
Think about the structure of their program. Take a look at all the classes, the constants, the interplay. Make some modifications to the code. Does it still work or have you broken it? Why did you break it? Is there a link that you didn’t identify?
saving score / loading statistics ...