Click here to Skip to main content
15,912,977 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: What is meant by Defensive Programming? Pin
Weylyn Cadwell3-Nov-15 2:00
Weylyn Cadwell3-Nov-15 2:00 
GeneralRe: What is meant by Defensive Programming? Pin
Maximilien3-Nov-15 1:07
Maximilien3-Nov-15 1:07 
GeneralRe: What is meant by Defensive Programming? Pin
Richard Deeming3-Nov-15 2:26
mveRichard Deeming3-Nov-15 2:26 
GeneralRe: What is meant by Defensive Programming? Pin
Maximilien3-Nov-15 2:47
Maximilien3-Nov-15 2:47 
GeneralRe: What is meant by Defensive Programming? Pin
kdmote4-Nov-15 5:05
kdmote4-Nov-15 5:05 
AnswerRe: What is meant by Defensive Programming? Pin
Super Lloyd3-Nov-15 1:21
Super Lloyd3-Nov-15 1:21 
GeneralRe: What is meant by Defensive Programming? Pin
Wynter Dragon4-Nov-15 4:16
Wynter Dragon4-Nov-15 4:16 
GeneralRe: What is meant by Defensive Programming? Pin
harold aptroot3-Nov-15 2:15
harold aptroot3-Nov-15 2:15 
Fundamentally the wrong way around, but with most languages you don't have much choice.

Really it should be guaranteed that all callers pass valid input, if they don't then it's the caller that's wrong, not the callee. But with defensive programming you'll get the assert in the callee, only at runtime, only if you're lucky, and it's up to you to figure out how it ever happened.

It's not like there's much of an alternative yet, but really calls that violate a callee's contract should be compile time errors, because if it's even possible to call something wrong, the caller is statically wrong.

GeneralRe: What is meant by Defensive Programming? PinPopular
W Balboos, GHB3-Nov-15 2:16
W Balboos, GHB3-Nov-15 2:16 
GeneralRe: What is meant by Defensive Programming? Pin
Marc Clifton3-Nov-15 2:22
mvaMarc Clifton3-Nov-15 2:22 
GeneralRe: What is meant by Defensive Programming? Pin
OriginalGriff3-Nov-15 2:29
mveOriginalGriff3-Nov-15 2:29 
GeneralRe: What is meant by Defensive Programming? Pin
Munchies_Matt3-Nov-15 2:39
Munchies_Matt3-Nov-15 2:39 
GeneralRe: What is meant by Defensive Programming? Pin
Eytukan3-Nov-15 3:24
Eytukan3-Nov-15 3:24 
GeneralRe: What is meant by Defensive Programming? Pin
BillWoodruff3-Nov-15 5:01
professionalBillWoodruff3-Nov-15 5:01 
GeneralRe: What is meant by Defensive Programming? Pin
PIEBALDconsult3-Nov-15 12:46
mvePIEBALDconsult3-Nov-15 12:46 
GeneralRe: What is meant by Defensive Programming? Pin
zandam3-Nov-15 22:35
zandam3-Nov-15 22:35 
GeneralRe: What is meant by Defensive Programming? Pin
Mycroft Holmes3-Nov-15 13:52
professionalMycroft Holmes3-Nov-15 13:52 
GeneralRe: What is meant by Defensive Programming? Pin
R. Erasmus3-Nov-15 23:29
R. Erasmus3-Nov-15 23:29 
GeneralRe: What is meant by Defensive Programming? Pin
Kirk 103898214-Nov-15 3:05
Kirk 103898214-Nov-15 3:05 
GeneralRe: What is meant by Defensive Programming? Pin
Ferd Really4-Nov-15 4:55
Ferd Really4-Nov-15 4:55 
GeneralRe: What is meant by Defensive Programming? Pin
Kirk 103898214-Nov-15 5:05
Kirk 103898214-Nov-15 5:05 
GeneralRe: What is meant by Defensive Programming? Pin
Sucramsy4-Nov-15 8:44
Sucramsy4-Nov-15 8:44 
GeneralFOSW OTD 03. November 2015 1. Hint Pin
HobbyProggy2-Nov-15 23:46
professionalHobbyProggy2-Nov-15 23:46 
GeneralRe: FOSW OTD 03. November 2015 Pin
Kornfeld Eliyahu Peter2-Nov-15 23:51
professionalKornfeld Eliyahu Peter2-Nov-15 23:51 
GeneralRe: FOSW OTD 03. November 2015 Pin
HobbyProggy2-Nov-15 23:55
professionalHobbyProggy2-Nov-15 23:55 

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.