From: Yochen Gutmann Date: 2006-08-08T05:37:14+09:00 Subject: Re: How to react on nil or wrong object-type as parameter So if I do understand you all correctly, in Ruby you put the responsible to the caller of a method (eg print_salary()). If you want to test that method, you test it only with the proper types. The next thing would be testing the method which includes the call of print_salary() if it calls this methods with the wrong types of parameter. Is this right? One problem in this concept is that if some operations might work on a parameter-object and the following is not the exception is thrown when the object is already modified. class Bank @invitations_to_golf def handle_client_well client client.decrease_acoount(200) client.check_portfolio @invitations_to_golf.push client end end jon_doe = LowBudgetClient.new big_boss = VeryRichClient.new big_money = Bank.new big_money.handle_client_well big_boss big_money.handle_client_well jon_doe // poor guy has no portfolio So, when the hcw-method is called with jon_doe, he has to pay for better handling but since he has no portfolio the exception is thrown before he is entering the golf course. One solution might be a exception around the method-body (yes, again ;-)) and a include an ensure to increase the account again if something broke. But again, this procedure would fail if there are many modifing operations. Perhaps I am still thinking too Java'ish and these are high theorectical problems or I still dont get it. Yochen -- Posted via http://www.ruby-forum.com/.