Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If we are doing OO programming, and we have rectangles, IsSquare would be a good method for a Rectangle whose dimensions are mutable rather than Square being a subclass of Rectangle.


Now you have to remember to check (and repeatedly check) IsSquare at runtime to somehow deal with rectangles that aren't squares, which probably means throwing an exception that someone else has to remember to catch or face runtime errors. But if the dimensions are mutable, no alternative is very satisfactory.




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

Search: