Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Writing efficient code
Old 02-27-2009, 12:44 PM Writing efficient code
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
It's midday, and I find myself looking at a few hundred lines of code, the product of a few hours work. I know because of the scope of this project, and how much more lies ahead, there's going to be a lot of need for optimizing what I'm creating. I find myself constantly tweaking it here and there, not only trying to make it more clean and readable, but smaller and more efficient.

I write a lot of JavaScript, mostly within jQuery or Prototype, and making things work efficiently is pretty important. I don't have a routine for testing how efficient my work is, but I do usually have a good feeling for what is working and what isn't.

Does anyone have any tips for how to write efficient code, or want to share experiences that have been helpful to you in this area? I'm interested in hearing about any platform or language.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
 
Register now for full access!
Old 02-27-2009, 08:53 PM Re: Writing efficient code
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
I'd say a few things:
  • Be careful not to optimize too early on. I'd get it working first and then profile it to see where it's bogging down. For JavaScript, Firebug is great for that. Once you see where the bottlenecks are, then you can work on those parts, but it save you from working on things that aren't a problem.
  • Separate your code so that each function or method does only one thing. It's more maintainable and you'll find it easier to optimize when you need to do so.
  • Especially when working with JavaScript, use GZip compression. You can do it through Apache or you can use a script to enable it. You can get around 70% savings on download size with GZip.
  • Leave your comments, etc. in the code and use a script to concatenate your JavaScript files into one or two files and then minify them.
  • If you've never checked it out, I'd highly recommend MooTools. They have a class based system and the plugins I've seen for MooTools generally tend to have a higher quality of code because of it over some of the other libraries.
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Reply     « Reply to Writing efficient code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19191 seconds with 12 queries