Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> This is why Varnish is written in "pidgin C" style and lousy with asserts which don't do anything, except clarify programmer intent, and in case of mistakes, stop bad things before they get out of hand.

Today I learned a new name for my C coding style.



'Assert early and often'. Check your assumptions all the time, nine out of ten times that's where your bugs will hide.


My C programs always start as a few skeleton .h files with include guards, and a few .c files that are basically an ever growing list of asserts() on any pointer to a structure or variable, or on any value where it is expected to be within a certain range.

Gradually I feed my structs and typedefs into the .h files and replace the asserts with (hopefully) working code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: