So I have been learning web development for about a year and a half. One key principle I like to focus on as I add a new tool to my arsenal is maintainability. This was not always the case and I will curse myself until the end of time for not caring about it earlier. It makes sense though, when you're just learning about how a programming language works it's very hard thinking about how to make your code maintainable, you just want it to work. Now that I understand why it's important, I want to write code that is easy to change and add to without risking too much recursion. This often means it takes me longer than expected to learn something new. However I feel this is the best approach. To make sure it's set up properly from day one. To make sure I can expand and adapt to new changes without pulling my hair out and rewriting half my code. This saves myself and anyone I work with time and energy. I feel this will help set me apart from the pack of "new to tech people" rushing to get any coding job.
It works why do I need to do more
Once a feature was working I used to think that was a fine place to stop. Not anymore, that's half the battle. Now I try to imagine that everything I add will need to be changed quickly in the near future. I feel this is just practical if I want to build websites for other people. Which is what I want to do. The only problem here is people want results and they want them within a deadline. Taking an extra few minutes here and there might not seem like a big deal but those minutes do add up. At the end of the day people often want their website up and running and don't think about maintenance. This is why I feel that learning to do things in a way that is easily maintainable the first time is crucial to my success as a developer long term.
Version control and how I once overlooked its importance
I use Git for version control. I use github for remote repositories. When I was struggling to learn how HTML, css and javascript all work together. Adding the complexity of using git on top of what I was already learning made my eyes roll back in my head. It felt unnecessary complex especially since I was building small websites to learn the craft, not large code bases for a software company. But the more I learned about not the how of development but the why, things started to clear up. I would make a few small changes to something I was working on and then the whole site stops working properly. If I had been in the habit of creating repos and pushing to them often throughout my work I would have saved myself some time and few headaches. If you are just starting out or struggling to understand how different languages work together, learn version control first. I know I wish I had.
Use Comments, good comments
I forget where I read this but somewhere in the many forums and blog posts I look at daily I found this gem.
"Write a comment about why something is done not just how it's being done"
If I had taken this to heart earlier I would have again saved myself time. I am sure you have opened up a project you haven't worked on in a while and struggled to understand your own code. It appears logical that a comment should explains how a section of code does something. It should but it should also say why. For example.
The following javascript function would update a user's score for a game of some type.
Function newScore(X, Y) {
let Z = X + Y;
Return Z
}
You could comment this as
// adds the inputs and returns the sum
Or you could comment
//sum of 2 integers
// x is previous score
//y is new points added,
//the returned value for Z is users new score.
//This is done as its own function for reusability.
When you're looking for clues as to how an application works, comments like this are extremely helpful. It tells you so much more than just what the function does. It tells you why it's done that way. This gives insight to the applications overall architecture.
5 minutes today could save you 5 hours tomorrow
While Comments and version control might feel like basic stuff everyone should know and use. You will be surprised at just how many people ignore these few steps. This only acts as a disservice to one's self in my opinion. These are simple things that can make your life as a developer a lot easier. I know they sure have made my experience better. Stay safe and have fun writing easily maintainable code.
Top comments (0)