Techdegree Journal 3 “Don’t Repeat Yourself. Seriously Don’t.”

Reading Time: 2 minutes

IMG_3521

Summary

I often like to take time out of coding on my computer, to go over old notes that I have written. What I have found is that once I’ve gone ahead and learnt new things, all the concepts that I found difficult, often like magic makes sense and this is where I get my lightbulb moments!

IMG_3518

One of the concepts that I found difficult to get my head around what is the “Don’t Repeat Yourself” (DRY) philosophy that was taught by the excellent Guil Hernandez on “CSS basics ” course at Treehouse

Guil explains that:

“DRY is a CSS philosophy where your aim is to write the most effective code with the least amount of lines possible. Repeated code makes the CSS style sheet harder to maintain and makes the browser work harder.”

Thoughts and Takeaways 

The DRY concept in a way it is like watching “The Sixth Sense” Movie for the first time. You think that you understand what’s happening and then the surprise twist at the end makes you realise that you’re watching a different movie all along (Damn you Bruce Willis!)

Initially I thought that DRY was concerned with the use of IDs and classes. But might been diesels voice, DRY goes a lot deeper than that. As I started to embrace dry, it helped me make my code cleaner, easier to understand and more readable.

For example, I saw the use of drying using shorthand. If I wanted to change the attributes of my particular font would be like so:

font long

Whereas if I use the font shorthand, it would be:

font long copy

Same thing but uses less lines of code:

Also HTML5 includes new elements that help make your markup more readable. For example if I was styling a simple webpage and I was creating containers, I would have to use with IDs & classes to describe what they are like so:

div

Whereas with the new elements, they are self explanatory. Also notice there are less lines of code.

nav

Key Takeaway

Taking time to learn how to use class is affectively, learning shorthands and using new HTML elements can make your code leaner, cleaner and and help you become a better coder. It did for me!

Catch you again soon!

Karlwebdev

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s