Graphics Reference
In-Depth Information
of the words is misspelled. Just like making edits to text in an
image, this one could get very tedious as well.
Optimizing Code
Optimizing your code can be just as important as optimizing your
images in terms of both file size and processor usage. As with most
steps in your projects, it is always best to keep code optimization
in mind from the very start before you have written a single line.
However, we all know that there are times when we just need to
make it work as quickly as we can, no matter what it takes. The
trick to those hurried times is to remember that we need to set
timeasidesothatwecanlatergobackandoptimize,or
clean
up,
ll be passing on a few
suggestions that have either been passed on to me or that I have
found in my own projects over time.
our code. In the rest of this section, I
'
Don't Repeat Yourself
I often find that I remind myself not to reinvent the wheel while
I
m working on projects. An example of what I mean would be that
if I find myself writing a function that does something very similar
to another function I
'
ve already written within the same project,
I can usually modify the first one to serve the needs of both.
I remember a particular microsite I was working on at the same
time I was working on a large round of banners. Although it
'
snot
unusual to work on more than one project at a time or for those
projects to have tight deadlines, this site had grown in size and
scope as it progressed. While the project was in midswing, new
sections and functionality were being added that affected the way
the site was being programmed. The deadline, however, could not
be adjusted due to critical timing on a product launch.
In order to get the new sections built into the site, I had to work
fast. And because those sections were added after all planning had
been completed, I had to get a little
'
creative
in my programming.
The end result, I
m a little embarrassed to say, was a fairly tangled
web of messy code in which I had multiple functions completing
the same tasks on the same objects and variables. If you
'
ve ever
run into this situation, you know how confusing it can be to go
back in and make changes or fixes to that kind of
'
spaghetti code.
You quickly discover that you
'
re asking questions like,
Did I call
function A from there or was it function C?
or,
Well, I had to fix
function A and function B does the same thing
do I need to fix
it as well? Am I even calling function B from anywhere?
Once you
hit that point, you have no choice but to take the time to go back
and optimize your code.
Search WWH ::




Custom Search