Thursday, March 30, 2006

Why I am starting to dislike my CompSci cource.

Your program should end by coming to the end of the start() method. It is bad style to exit from within another method.

This was referring to the use of exit(n) ( System.exit(n) in Java ). So if your program's behaviour becomes undefined ( such as a data structure being corrupted ) and it becomes aware of that it should quit by stringing it's way back to the root ( main ) function ?

----

We don't teach the break statement as it is not considered good style.

Who says it is not good style  ?

matthew@gentoo_desktop /usr/src/linux/mm $ grep 'break;' *.c | wc -l
152

Breaks are a very important part of efficient loop control, just as goto is. Yes, goto.

matthew@gentoo_desktop /usr/src/linux/mm $ grep 'goto ' *.c | grep ';' | wc -l
469
 
It's claim to shame is mostly due to it's abuse for trivial applications, but eliminating it completely it just stupid.
 
---

They also teach that defining constants such as this is a very good thing.
 final int SECONDS_IN_A_MINUTE = 60;

 While i agree 100% that arbitarily defined values ( such as using a number to store a state ) should only be set in constants, using constants for things this simple can get quite silly.


--
Matt
paranoidgeek@gmail.com
Disclaimer: This made sense at the time of writing.

0 comments: