Syntax Errors

I had learnt it in CG1101 mid-terms but yet again I forgot about it. Colin Tan’s MCQ mid-term papers. Colin Tan likes to say that his mid-terms are easy, but they are not. One of the rather insidious ways is to test your meticulousness in reading code syntax. Code that is usually always compilable or at least disclaimed as compilable. That switch case missing break statements, you might not notice. A complicated inline statement that serves many functions might concentrate your gaze, overlooking an innocent if test statement that would not complete due to the &&. Or even code that would work but would not make logical sense are the minefields of error. You’ll have to compile the code in your head, read it line by line. Learnt that in CG1101 but forgot about it in CG2271, to my own loss, at nearly the last question. Time was short, an innocent switch-case came rang an alarm, why would anyone put empty cases? How many times would a certain function be called a following case statement? Cases that have nothing in it. I disregarded due to the the lack of time. Once in the 4 times, would that function be called. Wrong. Case 0 and case 3 were empty and had NO break statement, the function is called twice once a round through the cases.

Beware the code syntax. Slightly illogical code syntax should ring bells for you to watch out for.

Advertisements
This entry was posted in Modules and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s