Click here to Skip to main content
16,009,255 members

Survey Results

Who should take responsibility for library function calls?   [Edit]

Survey period: 17 Feb 2003 to 23 Feb 2003

When a library function is called, who is responsible for ensuring that the input data will not cause a program to crash, or worse - be susceptible to a security hole?

OptionVotes% 
The programmer calling the function should ensure the supplied input data is valid.11210.82
The programmer who wrote the library function should ensure that all input data is valid.43341.84
Both library function writer and caller should validate all input data independently.44042.51
Neither - just use try...catch blocks to handle any problems.504.83



 
GeneralProgramming by Contract Pin
rruge26-Feb-03 4:31
rruge26-Feb-03 4:31 
GeneralDebug vs. Release Libraries Pin
Henry P.22-Feb-03 13:26
Henry P.22-Feb-03 13:26 
GeneralSemaphores and Mutexes Pin
almc22-Feb-03 1:06
almc22-Feb-03 1:06 
GeneralA real world example: Win32 API Pin
Rodrigo Strauss21-Feb-03 13:34
Rodrigo Strauss21-Feb-03 13:34 
GeneralRe: A real world example: Win32 API Pin
Daniel Lohmann22-Feb-03 0:11
Daniel Lohmann22-Feb-03 0:11 
GeneralInternal or External Libraries Pin
fantastic_mr_fox20-Feb-03 22:25
fantastic_mr_fox20-Feb-03 22:25 
General2 sides of same coin Pin
John R. Shaw20-Feb-03 9:56
John R. Shaw20-Feb-03 9:56 
GeneralRe: 2 sides of same coin Pin
Chris Maunder21-Feb-03 16:17
cofounderChris Maunder21-Feb-03 16:17 
GeneralSurprising results, IMHO Pin
iGN19-Feb-03 9:24
iGN19-Feb-03 9:24 
GeneralRe: Surprising results, IMHO Pin
Member 3174719-Feb-03 10:02
Member 3174719-Feb-03 10:02 
GeneralRe: Surprising results, IMHO Pin
Brandon Haase19-Feb-03 10:41
Brandon Haase19-Feb-03 10:41 
GeneralRe: Surprising results, IMHO Pin
compiler21-Feb-03 6:48
compiler21-Feb-03 6:48 
GeneralRe: Surprising results, IMHO Pin
Andreas Saurwein20-Feb-03 1:15
Andreas Saurwein20-Feb-03 1:15 
GeneralRe: Surprising results, IMHO Pin
Baris Kurtlutepe21-Feb-03 7:49
Baris Kurtlutepe21-Feb-03 7:49 
GeneralError locus Pin
Gary Wheeler18-Feb-03 6:20
Gary Wheeler18-Feb-03 6:20 
I think each error has a 'locus' determined by the knowledge required to detect and/or remediate the error.

A library should expect to be used as a black box, and therefore should at least validate the assumptions it makes about its arguments. What's important is that the knowledge required to validate the library arguments lies within the library itself. Requiring the caller to validate arguments disperses that knowledge to multiple locations, increasing the probability that the error detection will not be consistent.

The caller does have a role to play in validation, however. It has knowledge of the context in which the library is being used. It is the caller's responsibility to validate its use of the library against that context. In this case, the library doesn't have any way of knowing the application's context, and therefore can't validate against it.

How the library or the caller handles a detected error is immaterial; it can assert, throw an exception, return an error code, or halt the program. Any of these responses is valid, depending upon the situation (and personal taste).


Software Zen: delete this;
GeneralHmmm Pin
Jörgen Sigvardsson17-Feb-03 11:24
Jörgen Sigvardsson17-Feb-03 11:24 
GeneralRe: Hmmm Pin
Andreas Saurwein20-Feb-03 7:49
Andreas Saurwein20-Feb-03 7:49 
GeneralNot exactly a library but Pin
Michael P Butler17-Feb-03 10:01
Michael P Butler17-Feb-03 10:01 
GeneralRe: Not exactly a library but Pin
Mike Nordell17-Feb-03 18:13
Mike Nordell17-Feb-03 18:13 
GeneralIf there were a strict rule set in stone... Pin
Paul M Watt17-Feb-03 9:57
mentorPaul M Watt17-Feb-03 9:57 
GeneralWhere are all the C devs? Pin
Shog917-Feb-03 6:56
sitebuilderShog917-Feb-03 6:56 
GeneralRe: Where are all the C devs? Pin
Tim Smith17-Feb-03 8:13
Tim Smith17-Feb-03 8:13 
GeneralRe: Where are all the C devs? Pin
Jeremy Falcon18-Feb-03 12:00
professionalJeremy Falcon18-Feb-03 12:00 
General*I* want to be responsible Pin
Nemanja Trifunovic17-Feb-03 6:24
Nemanja Trifunovic17-Feb-03 6:24 
GeneralWhere are all the C++ devs? Pin
Chris Maunder17-Feb-03 5:59
cofounderChris Maunder17-Feb-03 5:59 

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.