Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Tips for lazy coders

Saturday, September 21st, 2013 by Servage

All web programmers are lazy by nature, and constantly in search of ways to save time and effort, by doing quick, yet effective coding, albeit with some fun. In this post, I suggest some tips for taking decent short cuts.

It is nice that we no longer need to create punch cards or use “0” and “1” repeatedly to do programming. Instead, we use simple human words to instruct our modern computers to act. While this programming style can be easy and quite fast, we still need even faster and better ways to do coding effectively. Most web developers are hard pressed to accomplish their project in the shortest time span without missing necessary quality. If we look at  modern programming languages, we find them to be more comprehensive than their Stone Age counterparts. With each new version of PHP, ASP.NET, etc., we are getting more advanced and becoming more programing friendly.

The latest version of markup, HTML 5, has plenty of straight-forward tags, to help eliminate a bunch of repetitive coding patterns. Despite such progress, at the syntax level, we web developers still have to do lots of text input during our project documentation. Therefore, our mentality tends to lean towards searching for new technologies and tools to lessen our coding burdens. And for this reason we are considered a lazy community among other technocrats, because we are always in search of shortcuts.

Code Editors

During web programming, HTML coding is a necessity before jumping to other languages. Therefore, HTML editors become our fast friends. They provide us auto-complete tools, so you add next commands that allow quick tag selections, by jumping from one to another. If you download Sublime Text 2, an HTML editor, you have the ability to highlight code in case you make mistakes. This saves you from searching for an elusive needle in a haystack when debugging or facing any hard problem at the time of code execution or parsing. In short, modern code editors, be they free or paid, can save you lots of effort during web programming.

DRY Tools

As stated earlier, coding is an extremely repetitive process because unlike human languages, programming has a more limited vocabulary. Hence, you have limited choices to construct various syntax. We therefore tend to use a single word or word phrase in multiple contexts. In order to avoid repeating code, modern web programmers follow one guiding principle called, “Don’t Repeat Yourself” (DRY). They use techniques that allow changes to be made in one place or file which then takes effect in all related documents; so, you don’t need to open every single file each time to make repeated changes.

There are ‘include’ tags in PHP language that do this work beautifully. And you can include a PHP file in multiple instances of other PHP files. For this, you use a code generator, such as Hammer, on your Mac. In the majority of web pages, we are using templates, and when not, we can use the ‘Russian Dolls’ technique to save us from typing scripts on each page. Moreover, we have plenty of variables or mixins to reuse tons of CSS, such as properties and selectors. We can do this without retyping the same code over again. Alternatively, you can use a CSS pre-processor to wisely manage these tasks.

Another toolset working in your favor is authoring frameworks, like Sass, “Syntactically Awesome Style Sheets.” This serves as a Meta language that can be written over the top of flat CSS, that ultimately simplifies as well as cleans up the script, making it lighter to use repeatedly and manage code. Another, open source CSS authoring framework is Compass. This is used in projects with responsive designing to create automatic, browser-friendly code. Plus, it saves lots of headaches particular to responsive design tasking.

References & More Reading

The Web Designer’s Cheat Sheet
8 Things Every WordPress Developer Should Know

Tips for lazy coders, 4.5 out of 5 based on 2 ratings
Categories: Tips & Tricks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.