Rainer Deyke wrote:
On the other hand, if the object itself calls it own public member
functions, then no invariants should be checked.  Not being able to call
public member functions while the object is temporarily in an invalid
state is too strict.  This is a problem that I actually ran into while
using D, and one of the reasons for why I stopped using invariants.

A solution is to redesign what the class considers public and private. A public member can be a shell around a private implementation, and other class members can call that private implementation without invoking the invariant.

Reply via email to