3 Ways to Drastically Improve Your Programming Skills On Your Own | by Kurtis Pykes | Towards Data Science

I’ve always thought of myself to be a decent programmer, but, I’ve never had anything to measure it against. Well, that’s until I saw what a really good programmer looks like — now I’m obsessed with developing my skills.
Instead of explaining what happened, I’ll show you. The task was to refactor code that analyzes a wine quality dataset from the UCI Machine Learning Repository.
I recommend all readers attempt the challenge in the Google Colab I’ve created before proceeding with the rest of the article.
Disclaimer: This task is taken from the Machine Learning Engineer Nanodegree on Udacity.
Before I reveal the solution that enlightened me of my ignorance, let me show you the solution the course developers asked us to improve on ...
# Course providers solutionlabels = list(df.columns)labels[0] = labels[0].replace(' ', '_')labels[1] = labels[1].replace(' ', '_')labels[2] = labels[2].replace(' ', '_')labels[3] = labels[3].replace(' ', '_')labels[5] = labels[5].replace(' ', '_')labels[6] = labels[6].replace(' ', '_')df.columns = labelsdf.head()
It seemed like a pretty simple task. Here’s my solution...
# My improvement of the solutiondef remove_spaces(df):    cols = list(df.columns)    for i in range(len(cols)):        cols[i] = cols[i].replace(" ", "_")    df.columns = cols    return dfdf = remove_spaces(df)df.head()
One could argue that my solution is an improvement to their solution since it eradicates the repetitive nature of the code — therefore abiding by the Don’t Repeat Yourself (DRY) best practice from software engineering. However, it’s not the optimal solution and can be improved.
Here’s how the course providers optimized their solution...
df.columns = [label.replace(' ', '_') for label in df.columns]df.head()
Simple and elegant.
What annoys me most about their solution is that I understand it. I know the logic well. I can write list comprehensions just like they’ve done. But, I couldn't come up with that solution. Not once did it cross my mind to do a list comprehension which is crazy to think of it now because I used a for loop.
This blooper activated my latest mission. A day does not pass where I am not actively attempting to better my programming skills.
Below, I’ve listed 3 methods I employ daily to improve my programming skills.
It goes without saying... If you want to be a better writer, you’ve got to become a better reader — this means reading more books, as well as a wider range of books.
In the same way, if you want to become a better programmer, which effectively is a different form of writing, you should seek to read a lot more code, especially code from very good programmers.
Some Github repositories with really good code are:
Scikit-Learn
Findings from Stackoverflow by JJruner
Bootstrap
It doesn't stop at reading code.
There are plenty of books out there to help you become a better programmer — A popular book to get you started is The Pragmatic Programmer by David Thomas & Andrew Hunt — but reading, in general, is really useful as it expands your mind.
Note: By clicking on the book link above, you would be directed to Amazon via my affiliates link. I’ve also integrated geo-linking so if you are not in the UK, you would automatically be directed to your local Amazon store.
I’ll be honest, initially, I adopted the mindset of “if it works, then it’s good”. Refactoring code always gets put off. In hindsight, it’s actually quite daft. I would never publish an article without iterating over it once or twice to ensure I am conveying the messaging I wish to.
Of course, code refactoring serves a different purpose. The purpose of refactoring code is to either make the code more efficient, more maintainable or both.
To become a better programmer, you must set aside time to refactor. To improve your refactoring skills, you must learn about refactoring — this will give you an idea of what to look for. Lastly, ensure you devote a lot of time refactoring code. You can revisit past projects or others people's projects and modify their code to make it more efficient, maintainable, or both.
If you want to become a better writer, you have to write more. If you want to become a better cook, you have to cook more. If you want to become a better programmer, you have to write more programs.
A little hack you could steal to write more programs is to start by writing lots of small programs. This will allow you to crank up the amount of code you’re writing each day which would allow you to create a lot more programs.
However, a large number of small programs would not cover the scope of programming skills required to be considered a good programmer. At some point, it’s important to make the transition from writing lots of small programs to writing larger programs as this would reveal a new set challenges that would force you to become a better programmer.
While these methods are great if you’re working in isolation to improve your programming skills, in the real world, it’s likely you’re going to be collaborating with other people. From my little experience, true growth comes when you step out of isolation and begin to work with others, especially those that are much smarter than you since you can adopt their methodologies to become a better programmer.
If you think I’ve left some ideas out leave a comment so we can continue to develop in unison.
Thanks for Reading!
If you enjoyed this article, connect with me by subscribing to my FREE weekly newsletter. Never miss a post I make about Artificial Intelligence, Data Science, and Freelancing.