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

This Point class is a poor example because it does not have anything that is not part of its interface, and, as presented here, does not have any constraints on it.

The intended purpose of encapsulation is to try and preserve integrity of a system by restricting the ways a programmer might put it into an inconsistent state. Knowing that certain constraints are in place simplifies the problem of understanding and debugging a system.



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

Search: