2 ms·
Contrary to people's dislike of OOP, I think it pretty well solves the problem. You have objects, and calling a method on it may fail with an exception. If the
by gf000 2y ago
Contrary to people's dislike of OOP, I think it pretty well solves the problem.
You have objects, and calling a method on it may fail with an exception. If the method throws an exception, it itself is responsible for leaving behind a sane state, but due to encapsulation it is a feasible task.
(Of course global state may still end up in illegal states, but if the program architecture is carefully designed and implemented it can be largely mitigated)