From: Robert Klemme Date: 2003-04-25T20:38:49+09:00 Subject: Re: Design By Contract. "Mike Wyer" schrieb im Newsbeitrag news:Pine.LNX.4.44.0304251128030.1484-100000@hagbard.wyer.org... > > Since ruby is dynamically typed currently I don't see much chance to have > > DBC in ruby. You can't even fix argument types of methods in the > > interface. You can of course do argument (type) checking at runtime, but > > there's not static type information about arguments. > > I always saw DBC as the combination of pre-, post-, and loop variable- > conditions. There's nothing to mandate static, compile time checking, and > the flavour of DBC I'm used to is very much geared towards runtime checks. Hm, I've seen parameter types (or call it type constraints a la, "parameter must be conformant to type X") as one element of the preconditions. But then, maybe I've used static typed languages too long. :-) Thinking about this you could have the precondition checking code somewhere visible near the method signature and have this executed automatically. Did you check out the implementation by Andrew Hunt available from the wiki link I posted earlier? > There's no point evaluating a pre-condition unless you've been given > something to evaluate, which yells "runtime!" to me, but maybe I've just > been using dynamic languages for too long :) Well, some preconditions can be checked at compile time, i.e. if you know the value that is passed to a method invocation. But generally speaking you are right. robert