wtorek, 12 maja 2009

Roots of all evil

There are some roots of all evil that hides in code. Let me just enumerate them:

1. Premature optimization (yep, classic...)
I thought that was so obvious but reading self-paced training kit for 70-536 exam i came across that brilliant observation:
For example, you might have three numbers to store that are fairly small. The first number might have a maximum value of 10, the second a maximum value of 50, and the third a maximum value of 500. You could store these as three Int16s but you’d be wasting space. Instead, you should use a BitVector32 to store all three values in a single 32-bit number.

Come on... ;)

2. Bad abstraction (yep linq2sql, i'm talking about you. where are you hiding webforms?)
Just don't get me started on that (i hope i will write bigger notes about all of these points but now i'm just enumerating them)

3. Code generation.
IMHO code generation is just another way of doing copy & paste - one of my favorite programming principles.

4. Improper error handling.
If you can't handle your errors just, please, make them fatal. Display error page or whatever. All i want you to do is at least to write everything to error log and then fail hard. Let the carpet be covered in blood but don't do it silently. Writing stack traces on the screen is hmmm... controversial ;) Just please, don't swallow all the exceptions and do nothing with them.

Brak komentarzy:

Prześlij komentarz