Best ways to improve your coding skills
So, you’ve picked up an interest in programming. Maybe you’ve completed a few walkthrough tutorials, started a code boot camp, or are just trying to hone in on your basic skills. You still find that the majority of the workflow and code creation is not yet natural to you. How can you break through this barrier? How can you develop the skills necessary to feel like you know what to do the moment you sit down at your computer to work on your app? Most of your comfort will come with experience, but there are many ways you can ramp up your skills to be a better developer in a shorter amount of time. Check out my tips below!
Get Comfortable with the Command Line
Perhaps a daunting task for new developers, getting familiar and comfortable with the command line empowers you to learn more about your application and its errors than simply writing the code and watching it fail in your local environment. If you are new to the command line, keep a list of common commands handy - it will be a good resource as you’re starting out, and with repetition, you will begin to memorize those necessary commands. Once you are comfortable working in the console, you may begin to utilize shortcuts such as aliases to increase your speed. A deep understanding of the command line will allow you greater control over your application, version control, environment, machine, and more.
Let the Tests Guide Your Development
Thorough tests will teach you more about your application than anything else. Various testing strategies exist and are valuable in different situations, such as unit testing, system testing, regression testing, and acceptance testing (just to name a few). At Gaslight we value TDD (test-driven development) which empowers us to write tests before we code. Once you have a firm understanding of what your new feature needs to do, break it down into individual cases. For example, if you are working to create user accounts for a feature, you will need tests for the creation, editing, archiving or deletion of accounts. You will need tests for incorrect usernames or passwords, for resetting passwords via an emailed link or a redirect, and for OAuth if your system will utilize it. These are just examples of tests that can exist for account creation and management; you will find more specific cases based on the exact specifications of your feature. Write these tests first, run them, and watch them fail. Then, write your code to perform those (and only those) actions, and watch the tests pass. TDD allows you to have a robust system without extraneous code, since you are only writing enough code to make the tests pass. You’ll encounter your errors right away and be able to fix them as they arise, which is much easier to handle than writing tests at the end and watching everything fail. You will need to get comfortable debugging in order to diagnose your failing tests, so we’ll dive into that next.
Learn How to Debug
Whether creating your own application or picking up work on a legacy system, you will encounter errors; there is no way around it. Take advantage of the Chrome developer tools, the console errors, and language-specific tools meant to assist you in understanding what your code is doing. Many times, error messages from failed tests will tell you exactly what is wrong with your code (this is why we love TDD!), but other times, you may need to do some digging on the internet. Running your code and tests often throughout the development process will show you new errors as they appear, which will help you pinpoint which changes caused the issue. You can also debug effectively by utilizing print statements in your code, checking the value of variables at different points in the console, setting breakpoints, or trying to reproduce the issue (if the tests don’t provide enough insight). Common errors to look out for are off-by-one math errors, spelling or syntax errors, or a missing semicolon or bracket. Finally, if debugging does not solve your issue, you may want to consider taking a different approach.
Refactor Existing Code
Whether you refactor your own code right after making the tests pass or refactor someone else’s code because it was written poorly, rewriting code will allow you to explore different ways to solve the same problem. Refactoring can be as simple as cleaning up the syntax to make the code read better, or it can be a full override of the way the previous solution was implemented. Regardless, you want the external behavior of your code to remain the same, but how it gets done might be different. When you refactor, you will learn to consider multiple approaches to a single problem. With repetition and time, this can turn into a skill that allows you to more easily consider multiple approaches upon feature creation, allowing you to weigh the pros and cons of various decisions and ideally make the best coding decision up front. Some factors to consider when refactoring are readability, organization, simplicity (get rid of that “clever” code!), efficiency, and clarity. While comments may help you and a future developer locate and understand certain algorithms, good code shouldn’t need paragraph-long comments; it should be clear what is happening! Feel free to still write comments - you and future developers will be thankful. Just keep in mind that if you need to use more lines to explain an algorithm than to code the algorithm itself, you may want to rework this solution.
Use Online Resources
You likely aren’t the first, and won’t be the last, to encounter that environment issue or to receive that confusing error message in your console. Learning how to search the web for shared solutions or advice will allow you to more quickly diagnose your issues and implement a solution. Many times, simply copying and pasting your error message into the search bar yields many StackOverflow results from developers that encountered the same problem. With practice, you can learn how to sift through the suggested solutions to figure out the best approach. This will require trial and error: you may encounter answers that seem effective, but end up not working due to different language versions, environment setups, integrations, and more. Part of this trial and error process will teach you how to look for the suggestions that accommodate what you need - even if it requires a combination of multiple approaches. Learning how to locate an issue and utilize other programmers’ suggestions will help you diagnose your own issues and become a more independent developer.
… and Other Humans!
One of the most effective ways to improve your coding skills is to work with others. Here at Gaslight, we value pair programming to increase code output, bounce ideas off of each other, aid in assisting mutual understanding of the client requests, and improve technical implementation of the solutions. Especially helpful for novice developers, pairing allows you to give and receive instant feedback about the approach to a solution, best coding practices, and catch errors more effectively. Simply utilizing another coworker to share ideas and code together allows quick absorption of new strategies while allowing you to discuss misunderstandings in real-time.
*BONUS TIP: While discussing things you don’t understand or learning new things with your pair, take notes! Not only will this become a great reference for the next time you run into this problem, but writing it out also reinforces what you learned. Being able to check back on your own notes instead of asking for the same help about a problem you’ve already discussed will promote greater team health and make you a more productive and resourceful developer.
Finally - Practice, Practice, Practice
As with any hobby, skill, or activity, you can perfect your craft by dedicating more time and effort toward your goals. Actively writing code and creating applications lets you experience, in real-time, the issues you will encounter throughout your development career. This allows you to understand best practices for debugging, how to lookup resources to solve or understand your problems effectively, and become more familiar with common structures and algorithms you will use commonly. You may be familiar with the 10,000-hour rule: Malcolm Gladwell’s theory suggests 10,000 hours of deliberate practice are required in order to master your craft. While experts debate the validity of the 10,000-hour suggestion, the underlying idea holds true: you will become better by pushing yourself and your skills for an extended period of time.