Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-10-29 21:00:14


"E. Gladyshev" <egladysh_at_[hidden]> escribió en el mensaje
news:20031030012929.90953.qmail_at_web40803.mail.yahoo.com...
>
> --- David Abrahams <dave_at_[hidden]> wrote:
> [...]
>
> > Can you give a "scientific" definition of what you mean by
> > "scientific?"
>
>
> I am not sure... some links/discussions/papers/books
> that elaborate on how and when object invariants
> can be broken and how to deal with that practically.
>
> I'd be especially interested to see
> how basic guarantees are useful in practical C++
> programming.
> Perhaps some practical usage cases.
> Are there any special considerations
> for breaking invariants and calling other methods
> of the broken object internally?
>
> You can imaging some examples like the following.
> struct type
> {
> //invariant is x + y = 10
> int x;
> int y;
>
> void f( int n )
> {
> x = n; //* invariant is broken
> f1(); //* is this allowed?
> y = 10-n; //* invariant restored
> }
>
The way I see it, if f1() is not public, then the above is most likely OK.
If is it public, then it is most likely not OK.
IMO invariants are an outside-view property of the object's state, thus,
during implementation procedures, these might not hold without it
representing a problem.

HTH

Fernando Cacciola
SciSoft


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk