From: "John W. Long" Date: 2003-11-08T11:29:11+09:00 Subject: Strong Typing (Re: Managing metadata about attribute types) Ryan, > > How can you prevent someone from using Strong Typing in the wrong > > way? > > I don't believe this is the right question. > > How can you prevent someone from using Strong Typing in the wrong > > way? These two questions where meant to go together, but they are a little confusing. What I meant was that a good api encourages people to use it in the right way (it won't prevent them from doing something stupid). My real question is more: Is there a better way to implement Strong Typing so that people will not tend to use it in the wrong way? I'm thinking of something along the lines of: def my_method(a, b, c) expect a to implement this behavior #this seems more ruby like expect b to implement ... end This is essentially what you have written. However it is also easy to implement it in a way more like statically typed languages: def my_method(a, b, c) expect a is a String #this is more like basic, java, or c expect b is an Integer ... end Most of the reaction seems to be against the second option. I could almost see this as a language feature: def my_method(a implements StringBehavior, b implements IntegerBehavior, c) ... end Or even: def my_method(a has DuckBehavior, b ...) ... end You could also implement this as an extension to Object: def my_method(a, b, c) if a.has?(DuckBehavior) a.waddle else #waddle is preferred over trot a.trot if a.has?(HorseBehavior) end end Strange thoughts. ___________________ John Long www.wiseheartdesign.com