Aug 8, 2017 · 1 min read
rectangle.width *= 2This way is totally not recommended in OOP design. Other than violates the encapsulation principle, it also has no “OOP” smell. The correct way is:
const doubleWidthRectangle = rectangle.doubleWidth();People can chose to go with this way or others, it depends. But my point is the mindset is more important here. Even if people using JS can easily making this mistake:
rectangle.width *= 2