Click here to Skip to main content
15,354,474 members

Survey Results

Do you do defensive programming?

Survey period: 14 May 2012 to 21 May 2012

"Defensive programming is ... intended to ensure the continuing function of a piece of software in spite of unforeseeable usage of said software". ie provide air-bags and ABS for your code. (suggested by the enigmatic V)

OptionVotes% 
Yes, I use defensive programming always19316.67
I use defensive programming mostly51044.04
I use defensive programming rarely19817.10
No, I don't use defensive programming design595.09
I have no idea of what you speak.19817.10



 
GeneralDefensive = secure Pin
ed welch14-May-12 6:22
Membered welch14-May-12 6:22 
GeneralDefensive, but not too defensive Pin
Nemanja Trifunovic14-May-12 4:43
MemberNemanja Trifunovic14-May-12 4:43 
GeneralNever developed a software with granted foreseeable usage... Pin
AlexCode14-May-12 2:50
professionalAlexCode14-May-12 2:50 
GeneralRe: Never developed a software with granted foreseeable usage... Pin
RedSonja14-May-12 20:51
MemberRedSonja14-May-12 20:51 
GeneralRe: Never developed a software with granted foreseeable usage... Pin
AlexCode14-May-12 21:15
professionalAlexCode14-May-12 21:15 
GeneralRe: Never developed a software with granted foreseeable usage... Pin
RedSonja14-May-12 21:51
MemberRedSonja14-May-12 21:51 
GeneralRe: Never developed a software with granted foreseeable usage... Pin
AlexCode14-May-12 21:58
professionalAlexCode14-May-12 21:58 
GeneralSaid yes to defensive programming but... Pin
PedroMC14-May-12 1:28
MemberPedroMC14-May-12 1:28 
What I consider to be defensive programming seems somewhat different from some descriptions floating around the internet. If I had to give a short description of what I consider defensive programming I would say "distrust, check, and if checks fail they do so loudly".

I think of defensive programming as two rules to follow while programming:

- A block of code (e.g. function) should never handle external data (e.g. function parameters, data returned from other functions) without strictly checking that the data it receives are know good values. If the checks fail they should fail loudly and the block of code should not touch the data at all.

- A block of code should have its behaviour checked (e.g. check return/result data, unit testing). If the checks fail again they should do so loudly.


I'm a strict follower of the first rule, but I confess that I'm a bit lax in relation to the second, especially regarding unit testing.

GeneralNo choice Pin
RedSonja14-May-12 0:32
MemberRedSonja14-May-12 0:32 
GeneralRe: No choice Pin
MichP14-May-12 8:36
MemberMichP14-May-12 8:36 
GeneralRe: No choice Pin
RedSonja14-May-12 20:36
MemberRedSonja14-May-12 20:36 
GeneralWhen given the time Pin
chriselst13-May-12 23:53
Memberchriselst13-May-12 23:53 
GeneralRe: When given the time Pin
Slacker00714-May-12 0:14
professionalSlacker00714-May-12 0:14 
GeneralRe: When given the time Pin
PedroMC14-May-12 1:36
MemberPedroMC14-May-12 1:36 
GeneralRe: When given the time Pin
chriselst14-May-12 1:40
Memberchriselst14-May-12 1:40 
GeneralRe: When given the time Pin
PedroMC14-May-12 1:49
MemberPedroMC14-May-12 1:49 
GeneralRe: When given the time Pin
chriselst14-May-12 1:54
Memberchriselst14-May-12 1:54 
GeneralRe: When given the time Pin
Fabio Franco14-May-12 10:15
professionalFabio Franco14-May-12 10:15 
GeneralWe have many defensive programmers. Pin
mojp13-May-12 23:16
Membermojp13-May-12 23:16 
GeneralRe: We have many defensive programmers. Pin
jim lahey13-May-12 23:50
Memberjim lahey13-May-12 23:50 
GeneralYes, I do Pin
Prasad_Kulkarni13-May-12 22:42
MemberPrasad_Kulkarni13-May-12 22:42 
GeneralRe: Yes, I do Pin
AlexCode14-May-12 21:26
professionalAlexCode14-May-12 21:26 
Generalone of the principals of testing Pin
R. Erasmus13-May-12 22:36
MemberR. Erasmus13-May-12 22:36 
GeneralWTF defensive programming Pin
Ra-one13-May-12 21:31
MemberRa-one13-May-12 21:31 
GeneralRe: WTF defensive programming Pin
OriginalGriff13-May-12 21:52
mveOriginalGriff13-May-12 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.