Getters and setters are the exact opposite of encapsulation: You don't hide any logic but expose everything directly. Yes, you can check things in a setter, but that's as far as encapsulation goes there. You want your classes to encapsulate _logic_. Instead of setting a state, you want to tell the class how to modify _its_ state. E.g. instead of set_x(), you want y_happened(), which implicitly updates x, hidden from the user of the class.