3 ms·
Personally, I think this is what 'encapsulation' is about. People have generally thought about 'encapsulation' as guarding the data but I feel that it is about
by solutionyogi 14y ago
Personally, I think this is what 'encapsulation' is about. People have generally thought about 'encapsulation' as guarding the data but I feel that it is about both data + behavior.
A quick tip: Any time you check an object's state to decide which method to call on it, you are breaking encapsulation. Call the method on the object and let it figure out what to do based on the state it is in.
- gnaritas 14y ago> A quick tip: Any time you check an object's state to decide which method to call on it, you are breaking encapsulation. Unless that object is self. But a good tip none the less.