Sign up for our newsletter

Email Address:

We endorse and use:

We use Code Spaces for our SVN Repository
We use nopCommerce for our open source e-commerce solutions
We use Umbraco for our open source CMS solutions
We use SilverStripe for our open source CMS solutions
We use SourceForge for our open source project hosting
We use the 960.gs css grid for our projects

Valid CSS!

Valid HTML 4.01 Transitional

What's in your...

Posted by Ed Nice on 8 September 2009 | 0 Comments

Tags: , , , , , ,

What's in your walle... errrm, utilities library?

This might seem like a silly question, but it's amazing how few developers and designers maintain re-usable code libraries.

If you use Dreamweaver, Visual Studio, Eclipse or any of the 101 editors out there, they all do 'boilerplate' pages for you. So why don't more designers and developers use their own default libraries?

So why is this a good idea? Simply put, it saves time, code size and errors. For example if you parse a regular expression in one page or script, then copy and paste the snippet into another page, this will [probably] work fine. The thing is, you've got 2 almost identical functions or expressions that could easily be added to a class file or a utilities script.

Why do programmers write duplicate code? Well, some have limited experience, some are probably a little lazy, some are really under time pressure and some have just always done it that way.

In the deep mists of time [about 15 years ago] when java was still an island in the ocean somewhere, most programming languages were very proprietary and often procedural in nature. This meant that the program generally got called, started at line 1 and ended at the last line. This all changed significantly with the introduction of object oriented languages. Amongst other things, it made programming a lot more flexible.

Ok, I know a lot of guys and girls do this. Especially in multi-user environments. There are still plenty that don't. Have you tried to change the VAT in an app that had 'vat = value * 0.175' writen about 30 times? Yes, this [hard coding the rate] is a really poor way of doing it, irrespective of repetition. 30 minutes, a value in a config file and a few public static fields in my utilities class and the next VAT change takes 5 minutes.

Not only will a change take a fraction of the time, saving my client money [they'll probably get this changed for free, it's that easy to do], when you are debugging and testing, you know the VAT is correct everywhere or not. And any other developers that follow me on this will thank me for it. I curse the chaps who left me with this and 1001 other duplicated code snippet nightmares.

And this doesn't need to be reserved for php,asp or java. You can create javascript libraries of your own [just look at jquery, prototype et al. Just great big re-usable chunks of loveliness] as well as universal CSS libraries that include things you use in every project like clear, centred pages and a host of other things.

So, guys and girls, remember to use those utility libraries. It'll save you a lot of time in the future.


Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments

Text size: Aa Bb Cc

Follow us on...

N-WebDesign news

Terms :: Privacy :: © N-Web Design 2012