|
![](/i/fill.gif) |
On 8/7/2011 8:00, Warp wrote:
> "In computer science, a predicate is called an invariant to a sequence
> of operations
Oh, and yes, if you're talking about DbC, You're basically talking about
OOP, so an "invariant" applies at the class level. Basically, any time the
constructor has finished and you're not inside a method of the instance in
question, that class's invariants should all be true. So a class invariant
is a predicate that applies at the end of the constructor and at the end of
each method and (ideally) at the start of each method. The only reason it
wouldn't apply at the start of each method is if someone changed one of the
objects that instance references. (E.g., your invariant is
this.mystorage.capacity > 100 and someone else goes around your back to set
mystorage.capacity = 50 because they have a reference to the same
"mystorage" instance.)
--
Darren New, San Diego CA, USA (PST)
How come I never get only one kudo?
Post a reply to this message
|
![](/i/fill.gif) |