100 days of code
I’ve been self teaching for about a year now and I found a strategy that works for me. I find that when I hear the same information from different sources, I retain it better and I make it a habit of seeing the same problem worked in different ways. The same way when I’m looking for a sunday gravy recipe… I tend to watch 7-8 cooking videos on Youtube for the same recipe. I observe what those 7-8 cooks are doing and what they all share in common, in terms of technique and ingredients.
I like to approach learning how to code in a similar manner. I’m currently enrolled in Team Treehouse and slowly working through several courses on Udemy. I’m also listening to coding podcasts and talks and this helps me figure out what the essentials are. You also find out how to do things and how not to do things.
One of the early CSS classes I took on Udemy was terrible. Even though I was a complete beginner, I could tell something didn’t feel right about the code, but I thought it was ok to do it this way since the final product seemed to function. The Udemy instructor kept using the CSS command “!important” on several lines right off the bat. Later, I find out that the command “!important” should only be used sparingly, but this asshole instructor had about 8 in the first 30 lines. The nerve of that guy to teach a course like that…but I digress.
Another early principle I learned is to “keep the CSS dry”. D.R.Y. stands for Don’t Repeat Yourself. The two sets of code below are the same exact code. They do the exact same and look the same on the screen. The only difference is that the first set has a lot of repeated commands. They have the “color” and “padding-top and bottom” repeated 3 times in the first set of code. The second version has no repeats and has less words. It’s easier on the eyes and easy to update or debug later on.
I’m not sure of the exact quote, but there’s a famous saying among chefs that said something like: a good chef’s goal is to make the best meal with as few ingredients as possible. I think it’s good to approach writing code in this way. There are, of course, times where it’s a good idea to repeat yourself, but as a general rule, I try to keep the CSS as “dry” as possible.