3 ms·
This is the way. The whole point of good object oriented design is that your class interfaces make it impossible to produce an invalid state of an instance. If
by UncleMeat 5y ago
This is the way.
The whole point of good object oriented design is that your class interfaces make it impossible to produce an invalid state of an instance. If you can produce a sequence of mutating or initialization method calls that leave a class with broken invariants then your interface needs work.
Incidentally, this is why the common "a square is a rectangle" example is usually broken. Calling setX() on a rectangle does not break invariants but calling setX() on a square does.