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

OOP encourages modifying an object's state via its member functions (if you use data hiding/encapsulation as part of your OOP definition). This means that users of class instances shouldn't be able to put it into a bad state, unless the member functions are able to put it in a bad state.

This lets you isolate where your contract/invariant violations are more easily. Once addressed in the member functions, either it fixes it in the callers, or their use is now invalid and becomes a compile or runtime error.



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

Search: