You could check the invariant in each modifier method just


Question: Suppose a class has an invariant condition that must be true for any objects of that class to be well-formed. You have at least two options regarding checking the invariant:

a. You could check the invariant in each modifier method just before it returns and throw an exception if the invariant fails.

b. You could document the invariant but not include any code that checks the invariant.

Each option is better in certain situations. Give at least one such situation where the first option is better and one where the second option is better.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: You could check the invariant in each modifier method just
Reference No:- TGS02578172

Expected delivery within 24 Hours