Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Rubinius wants to help you make Ruby better (engineyard.com)
57 points by raju on Aug 31, 2010 | hide | past | favorite | 4 comments


Once again reminding people to be careful about how they interpret the LSP:

http://www.reddit.com/r/programming/comments/7zy40/writing_u...


IMO the authors understanding of the LSP is incorrect. The way he uses it ANY change would be invalid, for example adding a new method would change the property of "raises AttributeError when attempting to access XYZ" (in Python parlance).


What you are criticizing isn't the author's understanding of the Liskov Substitution Principle. It is Barbara Liskov's attempt to formalize the Liskov Substitution Principle.

I dare say that she knows her own intent better than you do. It is also unsurprising if her formulation is imperfect.

In a practical world what the LSP means is that you should be able to replace an object of a given type with another object of any subtype and it should still work. If it doesn't, then that wasn't really a subtype. As you correctly pointed out, the challenge in dynamic languages with exception handling is that it is possible to write code that depends on a particular method not existing. Similar code in C++ would give a compilation error. Therefore no subtype can quite be perfect in some languages.

Still even though perfection is impossible, it is good to be aware of the principle, and adhere to it as closely as is practical. Meaning make your changes be one that will break the smallest amount of code that your code change is likely to encounter at any point in the future.


Not sure if I'm following, but if that method is never called, then does it apply to the system?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: