Good Code Solves Problems

Good Code Solves Problems

It should be a coder’s goal to make sure that every character in every line of code serves some purpose. The quality of code is not dependent on good form, prettiness, or theoretical benefits. Code should solve problems. HTML5 lets you omit closing paragraph tags and closing tags for list items. Some cringe at the thought of this, but it’s perfectly valid code. So if omitting extra tags helps your code become leaner and faster, then you’re solving a problem and that makes it good code.

CSS classes are customarily written in all lowercase and with hyphens. Yes, this looks pretty, but does it solve a problem? Maybe it’s more readable. That would be fine. But what if a combination of camel casing, hyphens, and underscores can help the readability and future maintenance of the code? Then it’s good code, because it solves a problem. For years many developers have preached about “clean HTML” and avoiding “classitis”, promoting this as a means to make documents more semantic. But in many cases, these semantics arguments have been theoretical at best. Yes, littering your HTML with extra classes might make your HTML a little bigger and slightly slower.

But the miniscule loss in page speed and “good form” is gained tenfold in CSS maintenance and modularity. Even a simple semi-colon left out of a line of JavaScript can seem so difficult for some to accept. But if its omission solves a problem (i.e. fewer characters) and it doesn’t have any other drawbacks, then it’s good code. Theory and future-proofing has its benefits. Good code, however, is code that has a purpose. Good code doesn’t just look pretty. Good code solves problems.

Article originally posted on 28th May by Impressive Webs

Copyright © 2007 - 2024 ITPIE

IT Pie is a trading name of ODR Creative Design Limited

Registered in England and Wales. Company No. 05625215. VAT Registration No. 158 4583 75

Close

Make a great decision today...

We’d be more than happy to chat without any obligation. Let’s find out if we belong together...

Tel: 029 2070 6336 or

fill out or form and we’ll get straight back to you...