Defensive programming is a style of programming designed to minimize the possibility of bugs introduced by code changes or unforeseen usage of the software.

learn more… | top users | synonyms

42
votes
8answers
8k views

Defensive Programming vs Exception Handling?

I'm working through the book "Head First Python" (it's my language to learn this year) and I got to a section where they argue about two code techniques: Defensive coding vs Exception handling. Here ...
26
votes
3answers
4k views

if ('constant' == $variable) vs. if ($variable == 'constant')

Lately, I've been working a lot in PHP and specifically within the WordPress framework. I'm noticing a lot of code in the form of: if ( 1 == $options['postlink'] ) Where I would have expected to ...
11
votes
3answers
244 views

Do I need to deal with the situation where private methods are called through reflection?

When creating a library, must I ensure that the private methods must work as expected when called not by other methods of the same class, but by another library through reflection? For example, if a ...