Design by contract is not built into Python as it is in Eiffel, but anyone that is aware of the concepts can use that style in Python as well as C, C++, Java, Ruby and so on. Java initially did not have support for assertions and so did not support the approach, that problem has since been corrected, however.
Richard----- Original Message ----- From: "Veli-Pekka Tätilä" <vtatila@xxxxxxxxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Monday, October 22, 2007 11:51 AMSubject: Re: Python experiences: Duck Vs Design by Contract was Re: Fruit basket program in Boo,Other Script Langs
Hi James, I think he means you can test correctness conditions in the code and optionally only include those tests in debug builds. Much like the assert macroes in C. Design by contract is about classes that are able to define and check method pre and post conditions for their objects, as well as invariant conditions that must hold true for the lifetime of the object. For Perl, for instance, there's the die operator, flags telling if the debugger is on, and modules like Class::Contract for design by contract programming. Is the design by contract really built into Python or is it a clever add-on module? Isn't the whole duck typing, and if there's a method named like that we hope it will work, philosophy against design by contract? I kinda like duck typing in Perl, Ruby or whatever, but still. Java's interfaces do force you to define an exact API. -- With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx) Accessibility, game music, synthesizers and programming: http://www.student.oulu.fi/~vtatila james.homme@xxxxxxxxxxxx wrote:Hi Richard, What does this mean in english?<snip>One more thing in the advantage column: Python, like many other languages, supports assertions. I am a strongadvocate of the "Programming as contract" concept as introduced by BertrandMeyer in the late 1980's in the Eiffel language. Python supports that notion, which can help ensure program correctness. Richard__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind