home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!rational.com!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Subject: Re: question on REFERENCES
- Message-ID: <rmartin.722281996@thor>
- Sender: news@rational.com
- Organization: Rational
- References: <1992Nov17.073603.5235@murdoch.acc.Virginia.EDU> <75096@hydra.gatech.EDU> <1992Nov17.141055.19557@relay.nswc.navy.mil>
- Date: Fri, 20 Nov 1992 17:53:16 GMT
- Lines: 26
-
- kestes@nswc-wo.nswc.navy.mil (Kent Estes) writes:
-
- |Hello netters,
-
- |I am working on a function that references objects via id. Upon finding
- |an object, it returns a reference to that object. My question is :
- |if the object is not found, what is the best way to handle this. If
- |I were returning pointers to objects, all I would have to do is
- |return NULL.
-
- My own preference is to return pointers if the functon can fail, and
- to return references only if the function cannot fail, or uses
- exceptions to report the failure.
-
- This provides a very convenient paradigm, to wit: References never
- need to be checked, pointers always do. This works equally well for
- function arguments where references must always be valid, but pointers
- may be zero.
-
-
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-