YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 01-27 Domains And Ranges Solution

01-27 Domains And Ranges Solution

Get Embed Code
1 Language

Showing Revision 2 created 07/16/2014 by Udacity Robot.

  1. The answer is that yes, we should test it with negative inputs.

  2. Negative inputs are part of the domain of a function,
  3. and one of the basic principles of testing is we should test computer programs
  4. with values sampled from their entire domain.
  5. Sometimes as a software tester, you'll test code with an input
  6. that looks like it should be part of the domain, and the code will malfunction,
  7. will crash with some sort of a bad error,
  8. perhaps maybe not throw an exception but rather actually exit abnormally.
  9. And what you'll do is you'll go to the developer of the function,
  10. you'll go to the developer of the software under test,
  11. and you'll say, "I think I found a bug,"
  12. and they'll tell you something like, "Well, the input that you tried
  13. "is not part of the domain for the software."
  14. That's usually perfectly legitimate.
  15. As long as that kind of fact is documented,
  16. as long as it's clear to the users of the function,
  17. then restrictions on the domain of functions are actually a very valuable tool in practice
  18. because otherwise, without restrictions on domain,
  19. every function that we implement, every piece of software that we implement,
  20. has to contain maximal defensive code against illegal inputs.
  21. And in practice, this kind of defensive coding is not generally possible for all internal interfaces.
  22. For one thing, it makes code extremely slow,
  23. and for another thing, it clutters up code with error checks
  24. that make it completely impossible to find the code
  25. that's actually supposed to be doing something.
  26. So to reiterate, domain researches are a perfectly valid technique
  27. for keeping code simple in the case where these kind of assumptions about input domain
  28. are actually reasonable.