|
Hello Martin, >>> You think of runtime validation of parameters? Thats insane
concerning performance and performance is what flash lacks in. I talk about describing test situations – no matter
whether you call it unit tests or DBC or something else – to be placed at
the head of a method or a class. Both are nice places, where every Jane and Joe programmer
could easily find unit tests DBC description or whatever tests someone could
think of. You no more would look around in folders to find files
that might do tests onto classes and you would have to know about the places of
those tests. One place right under the class head or method head
would be a very nice place everyone could find. Regards Bernd Von:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Martin Heidegger You think of runtime
validation of parameters? Thats insane concerning performance and performance
is what flash lacks in. 2006/10/8, Bernd Will < [EMAIL PROTECTED]>: Hello Martin, You like to put the stuff outside the classes,
while I would like to see tests and validation being embedded as a kind of
class documentation. Regards Bernd Von: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] Im Auftrag
von Martin Heidegger
I merly know about DBC what Wikipedia tells me. 2006/10/8,
Bernd Will <[EMAIL PROTECTED] >: Hello Martin, you mean that every class should get an interface
? DBC is more than just a syntax check, DBC allows
pre and post checking as well: http://www.wayforward.net/pycontract/ Regards Bernd Von: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] Im Auftrag
von Martin Heidegger
Well - so what? Unittests together with interfaces
seem to be a strategy that matches enough - doesn't it? 2006/10/8,
Bernd Will < [EMAIL PROTECTED] >: Hello Martin, "Interface" allow syntax check during
compile time. "Tests" allow semantic validation
during runtime. Regards Bernd Von: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] Im Auftrag
von Martin Heidegger Betreff: Re: [osflash] Design By Contract
on ActionScript 2 To me working with interfaces is DBC. A object has a
interface that allows certain usage this usage is documented and tested with
unit tests. is there a need for more? 2006/10/7,
Bernd Will <[EMAIL PROTECTED] >: Hello everybody, similar to doctest, DBC in Python is also easily
injected by inserting inside those comment tags at the beginning of a method. It is very nice seeing UNITTEST and DBC in one
comment placed directly below the method's head. Here an example for UNITTEST and DBC in Python: def sort(a): """Sort a list * >>> a = [1, 1, 1, 1, 1, 2, 2, 1]>>> sort(a) >>> a [1, 1, 1, 1, 1, 1, 2, 2] >>> a = 'the quick brown fox jumped over the lazy dog'.split() >>> sort(a) >>> a ['brown', 'dog', 'fox', 'jumped', 'lazy', 'over', 'quick', 'the', 'the'] pre: # must be a list isinstance(a, list) # all elements must be comparable with all other items forall(range(len(a)), lambda i: forall(range(len(a)), lambda j: (a[i] < a[j]) ^ (a[i] >= a[j]))) post[a]: # length of array is unchanged len(a) == len(__old__.a) # all elements given are still in the arrayforall(__old__.a, lambda e: __old__.a.count(e) == a.count(e)) # the array is sorted forall([a[i] >= a[i-1] for i in range(1, len(a))]) """ a.sort() # enable contract checking import contract contract.checkmod(__name__) def _test(): import doctest, sort return doctest.testmod(sort) if __name__ == "__main__": _test()
|
_______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
