“It is impossible to live without failing at something unless you live so cautiously that you might as well not have lived at all.”
I use this J.K. Rowling quote every day to remind myself to step out of my comfort zone because I am a cautious person. Sometimes that can impact my coding.
Before I started my first day of front-end web development, I made a list of the main mistakes people usually make when they start coding, to see what I could anticipate and dodge ahead of time.
Here are some of the things I read and found to be true in my coding classes:
Watch your formatting: A beginner can almost instantly be spotted when they use messy formatting. Code should be indented correctly, and there should be consistent use of new lines and white space. Indenting code is how to show logical structure. Consistency in format is critical. This way you don’t wonder where things are all the time.
Take out commented sections that you don’t need. A big goal of a coder should be to have code that self-documents — this means that the variable, function, class names and structure relay the message of the code itself to others without the need for additional side-comments.
Commenting is still valuable, but should only happen when necessary and should always be concise. The purpose of comments is to provide a document if you need to go back and remember what you did.
Be careful of the inconsistent use of uppercase and lowercase in your variable and function names. Also, it’s important to note that the usage of uppercase and lowercase varies between languages.
Use meaningful variable and function names. It’s essential that your code’s intent is clarified. If you have two variables with the same name in different places, it can disrupt the flow of your code. Avoid spelling mistakes in your variable names, and don’t use slang. Form practical naming conventions.
Ultimately, coding companies have standards. You will need to learn how to conform to those standards, so this is good practice in the meantime.
RELATED STORY: Starting Out in Tech: How to think like a programmer
Never start coding without a plan: Before you start in on a program, make sure you understand all of the requirements and what it needs to do.
Consider its design — you need to understand how it will work internally. How will the interface look and how will it be navigated? Design a test in advance — this will help you lay it out.
Try not to overcomplicate things: Your code needs to be simple so it will be used, re-used and extended. Your code should be able to be extracted into its own module. The simpler the code, the fewer bugs you’ll have, and the less time you’ll spend debugging.
Take advantage of debugging tools: A debugger gives the programmer the opportunity to sift through the code to better, more fully understand what it’s doing. This step is critical for a program that’s not working, but it’s just as crucial for a program that appears to be working fine. The debugger gives you more information to work with when you need a more detailed understanding of what your program is doing.
Always, always backup your work: You can use Dropbox or Github for safer, backed up versions of your code. There are inexpensive systems that back up the entire disk on a nightly basis.
Run tests throughout the development process: Always test on major browsers while you’re building your code to avoid any surprises. Do not leave testing until the last minute.
Don’t doubt yourself: Beginners always seem to be convinced that they aren’t smart enough to make it in programming, that there’s a specific type of brain that they need to have — there isn’t.
These are all good things to keep in mind while you’re starting out in coding. It’s always good to be careful, but if you are too worried about making mistakes in coding, you’ll never learn. The more mistakes you fix, the more you’ll learn about what you don’t know.
It’s vital that you not only learn how to solve problems but learn how to solve them in different ways. That’s what coding is all about. So stop worrying about failing and go for it!
Join the Conversation: What are your rules to live by when writing code? Share them on our Facebook page.
Coming Next Week: Jaimie introduces the coding language Python. Are you ready?