Hacker News new | ask | show | jobs
by bad_user 5317 days ago
Maybe my example wasn't clear enough.

How about if you want to do stuff only with Employees with a salary greater than X? Consider this case ...

   a_employees = employees.filter{|x| x.salary > A}
   b_employees = employees.filter{|x| x.salary > B}

   # where A > X, B > X
   # so both should work with:

   def do_stuff(employees) where employees.salary > X
       ...
In other words, creating new subclasses is a poor substitute for code contracts, especially since many contracts could be checked at compile time.