Nov 09, 2011
Table of contents:
As Internet usage rises, the ability to code, or understand how a website or web application works, will become ever more valuable. Not everyone wants to become proficient in the nuances of every programming language, but it is extremely useful to be able to understand programming in general. This post is really aimed at the business people of a start-up, Web Designers or people that have or want to have active input into a website, but feel they are held back by an inability to understand code.
Here are my 3 simple rules for understanding how to code.
This is really the most crucial aspect of learning how to code. If you can map out exactly what you need to achieve, then coding the problem will become a lot more simple. I find the best way to really understand how something will work is to either map it out on paper, or write down the process in structured sentences.
Mapping out the problem allows you to easily see how the different aspects of the problem can be broken down into smaller chunks. You can then see how those chunks will work together to solve the problem.
Writing out sentences of what needs to happen is again a good way of understanding what you need to do. This can also highlight some of the syntax you will need when it comes to writing the code. For example;
If the the counter equals 10, then I need to query the database, otherwise I send a message to the user
This first step needs to be completed without writing a single line of code. If you can understand exactly what you need to do, actually writing the code to achieve it will be a lot easier.
Now that you have the logic nailed down, you will need to find the right tools to realise your vision. Programming languages are so extensive, that learning any in depth requires a lot of time and effort. For this post, our goal is to get the minimum understanding to achieve what we want, so don’t waste your time learning everything you can about PHP or Ruby, because you don’t need to.
Once you understand the logic of what you are trying to achieve, you can simply Google what you need. Stack Overflow has become the best place online to get programming questions answered. If you need to achieve something, it has probably already been asked by someone else.
Make sure you break down your logic sequence into small chunks that require action. You can then Google how to do that action in whatever language you need.
For example, say you wanted to change the first letter of a word to a capital letter in PHP. You would type into Google “capitalise first letter php” and more often than not the first result will give you exactly what you need.
When I’m writing out a section of code which is new to me, I often try and save time and not test each little bit as I’m going to ensure it is working as I want. This means that when I do finally come to test it, the problem isn’t always obvious and I have to either re-trace my steps, or start a fresh and build it again.
As you are building each chunk of your code, always test it as you are going to ensure that the outcome is exactly what you expect. This may seem like it will take much longer, but trust me, it will save you time in the long run.
Once you understand what each section does, you can build on that understanding to re-use those same functions in future tasks. When you learn a programming language, it would be stupid to try and just learn every nuance straight away. Instead, only learn the bare minimum of what you need to achieve what you want, then slowly let it build up over time.