Re: [boost] Re: [review] Formal review of

In-Reply-To: <ck6la2$kki$1@sea.gmane.org> nesotto@cs.auc.dk (Thorsten Ottosen) wrote (abridged):
Conclusion: disallowing 0 will not only lead to simpler, safer programs, but it will probably also boost performance.
The null object pattern can only be used if all the object's member functions have trivial post-conditions. If instead I have code like: dog.walk_to( pTree ); assert( dog.location() == pTree ); // ... more code assuming the dog's location. then it is not going to work with a null_dog. If people use it anyway there will be tears before bedtime. Of course, this is no more an argument against ptr_vector<Dog> than it is against std::vector<Dog>. I think the problem here is the name. "ptr_vector" sounds so much like a vector of pointers that people expect null pointers to be supported. There is a gap between what those people want and what ptr_vector supplies. The null object pattern is not a solution here. It just papers over the crack. -- Dave Harris, Nottingham, UK

"Dave Harris" <brangdon@cix.compulink.co.uk> wrote in message news:memo.693391@cix.compulink.co.uk... | In-Reply-To: <ck6la2$kki$1@sea.gmane.org> | nesotto@cs.auc.dk (Thorsten Ottosen) wrote (abridged): | > Conclusion: disallowing 0 will not only lead to simpler, safer | > programs, but it will probably also boost performance. | | The null object pattern can only be used if all the object's member | functions have trivial post-conditions. If instead I have code like: | | dog.walk_to( pTree ); | assert( dog.location() == pTree ); | // ... more code assuming the dog's location. | | then it is not going to work with a null_dog. If people use it anyway | there will be tears before bedtime. could you post your real code along with reasons for putting a null into the tree and maybe some comments about the density of null's in the tree. Thanks Thorsten
participants (2)
-
brangdon@cix.compulink.co.uk
-
Thorsten Ottosen