Could TDD be a valid alternative to data validation?

Consider these two data validation scenarios:

Check everything everywhere

Make sure that every method that takes one or more arguments actually checks them to make sure they are syntactically valid.

Arguments

  • Very fine check of detail.
  • If the written code is intended for any library, we must limit the damage that may be caused if the developers who use it cannot provide reliable data.

vs

  • You should always perform checks that most of the time you do not need.
  • You can still forget to add a check from time to time.
  • Next, the code is written and, therefore, needs maintenance.

Use TDD Kindness

. , , , , . , .

.

, , , , , , .

, , , .

+3
5

, , , , , , .

, , .

TDD , , , , , , 3 4 . , , .

, , ( ), , , , , . .

, , , , , .

, , . , , , , , .

, , , , , , , , , , , , , .

, , , TDD.

+2

, :

  • .
  • , , .

, TDD , . ...

, ( , ), : - , . , , GIGO. .

TDD, ( ), , , , . , , , , - , . , , TDD , .

, , , , TDD ( TDD ).

+1

, , , .

, .

, :

  • , ,

, . , , , . , , .

0

. ,

, , .

, . , , . , ArgumentNullException . TDD ( Fuzz Testing).

0

, , , .

.

, :

  • , :
  • :

overkill :

  • , :
  • : , .

: , , (), , , , . . : . , , , , .

, overkill . , ( - ). , , . 90 . , , . : ? ? ? , (, ..)? , . , . , DIVIDE-BY-ZERO ?

Another problem is that in many cases you simply do not know what can be done with a statement error. If you are at a real entry point, you can return something that is understandable to your user or lib user ... when you check the internal functions.

0
source

Source: https://habr.com/ru/post/1716917/


All Articles