Can Design-by-Contract be applied to dynamic languages as easily/well as to statically-typed ones?

StackOverflow https://stackoverflow.com/questions/649020

Question

The title pretty much sums up the gist.

I'm interested in whether it is possible to enable/disable contract enforcement(s) when using a dynamic language without running a serious risk of poorly/un-diagnosed failure?

If not, the crux seems (to me) to be that any enforcements are a required part of the component's logic, rather than optional/removable as per the spirit of removability of DbC's enforcements.

Was it helpful?

Solution

Not only is it possible, there are real-world implementations of this and they've been around for years. Here's a DbC implementation for Python that's twelve years old, for example.

OTHER TIPS

I believe lisp has a good design by contract framework.

http://www.cl-user.net/asp/OkD82/sdataQkIGW7mlSHARDQ3r-H8X8yBX8yBXnMq=/sdataQu3F$sSHnB==

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top