Campbell Ritchie wrote:It is best to reduce mutability as much as possible.
Took notes!
Campbell Ritchie wrote: Also, setXXX() and getXXX() methods may break encapsulation and therefore violate some of the principles of object‑orientation. (Old thread about setXXX() methods.)[/list]
I'm still learning on objects and honestly, I gave a pass on Abstraction and encapsulation. Both seemed confusing. I felt both are same. But today I gave another reading, and I still feel both are same.
Campbell Ritchie wrote:2: If you allow the field to retain its default value, you will have your object in an inconsistent state; there is no such thing a a circle with radius 0. You might have radius 0.000...0001 but not 0. Remember there is no way to “force” your users to call any setXXX() methods.
I couldn't find on references on leaving object values to defaults will leave object in inconsistent state. I would like to know more about this. Can you please give me any reference to this subject area?
Campbell Ritchie wrote:Don't call the method Calculate() with a capital C. Say calculateArea() or similar instead.
Ah.. the basics said this. I forgot. Below code after changing.
But there's confusion. I think I need to start reading objects from concepts from beginning again.