Posts

Showing posts from February, 2008

Note on Programming Practice

I have been attending 2 code review sessions since coming back from Tawau. Here's what I've learned. Put comment into the source code, i.e. what it does, and which function is calling it. Exception handling on HANDLE that could not be closed properly. Code that repeats several times can be put into 1 function. This way, it will be centralized and easy to debug. Pointer must be deleted to avoid memory leak. std:vector can be used instead of fix size array. It is better not to use query all statement to query everything out from the database. strncpy and strncat are safer way to manipulate string. Construct an exception class to throw error instead of throwing number. Don't use too much pointer if can. Database connection must be caught and handled. Have constant localized at 1 place. This way, it makes it more easy to manage. Declare only the functions that need to be interfaced with other class as public; otherwise the rest should be private. Use const keyword to avoid a