Thursday, May 22, 2003

Beware of Tattoo Artist! Especially if you don't know the language he writes in ! Heh.
"At the end of the day, this is an ugly boy."
Jeez. I'll remember to stick to images or non-literature symbols while searching for the perfect tattoo.
Added, in the first 14 minutes of Friday Morning:
It may be necessary to copy the other javascript code into a separately linked file, so that the file links independently of the damn blogger html site, since it's having serious problems loading the whole damn blog !
Well, here's the first of my newest series, Good Coding Practices. The first few may seem a bit simple, trite, or glaringly obvious to some, but unfortunately, not all individuals. But I figure it's a good base to start from:
Good Coding Practice #1:
Always put opening brackets on separate lines below declarations. You will often see it the other way in books, and I've actually had people attempt to convince me by saying, "Man, I'm telling you, this is how the professionals do it! Trust me!"
Too bad. I'm more concerned with readability. :-p Instead of :
int aFunction(parameters) {
/* A lot of Code */
}

do this:
int aFunction(parameters)
{
/*A lot of Code */
}

It may seem nitpicky, but BELIEVE ME when I say that it neatly walks all the way around the problem of nested scopes from hell and forgotten closing brackets.

Good Coding Practice #2:
Naming and organization is important. don't have two separate functions in different files with the same name, and don't have the same function in different files.
use header files, prototypes, and file linking ... in javascript the headers and file linking is equivalent to <script type="text/javascript" src = someURL> . It's easier to read and understand. And in larger projects, you'll want to use folders ... make sure your source code organization is logical, because it can soon become a nightmare . There IS a point at which a program gets so big that you will have forgotten some names and details of other parts of your code, and when you reach it, you will want easy access.
Good Coding Practice #3:
In C and C++, array subscript notation for any array anArray of type someType with an integer index i, or :
someType anArray[i] is usually compiled as:
*(anArray + (i * sizeof(someType)) )
Thus, when using a significant amount of array operations, if your code is time-sensitive in some areas, then it may be worth while to investigate the increase of speed by simply using pointers to access the array's contents. i.e. this:
for (int i = 0; i < length; i++)
{ /*some code involving anArray[i]*/ }

becomes this :
for (someType *ptr = anArray, *end = anArray+length * sizeof(someType); ptr < end ; ptr+= sizeof(someType))
{/*some code involving *ptr */}

just a quick example. You'd probably want to beautify that code somewhat more.
There's also some interesting information about loop inversion, but until I run my own tests, I'm hesitant to post it ... in fact, I'll run tests on this one, too :-p