Re: Question on Effective Java Item 27
- From: "S Perryman" <a@xxxxx>
- Date: Fri, 21 Apr 2006 08:32:26 +0100
"Andrew McDonagh" <news@xxxxxxxxx> wrote in message
news:e28d7c$14v$1@xxxxxxxxxxxxxxxxxxxxxxxx
S Perryman wrote:
Because I haved programmed in different prog langs, I try to have a
consistent approach for a problem regardless of the prog lang.
So here it is multiple out parameters, or a suitable result type.
But never null = not found.
null for not found is common in Java though
e.g.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html#get(java.lang.Object)
HashMap
public Object get(Object key)
Returns the value to which the specified key is mapped in this
identity hash map, or null if the map contains no mapping for this key. A
return value of null does not necessarily indicate that the map contains
no mapping for the key; it is also possible that the map explicitly maps
the key to null. The containsKey method may be used to distinguish these
two cases.
QED.
Seriously though, certain prog langs have entrenched this approach into
their
culture. And then it becomes defacto.
When I first had to use C in industry, and suggested using either of the
discussed approaches on a project, you should have seen the nasty looks I
got (in addition to the "bloody graduate, what does he know" stuff) ... :-)
Regards,
Steven Perryman
.
- Follow-Ups:
- Re: Question on Effective Java Item 27
- From: Daniel T.
- Re: Question on Effective Java Item 27
- References:
- Question on Effective Java Item 27
- From: hforco@xxxxxxxxxxxxxx
- Re: Question on Effective Java Item 27
- From: S Perryman
- Re: Question on Effective Java Item 27
- From: hforco@xxxxxxxxxxxxxx
- Re: Question on Effective Java Item 27
- From: S Perryman
- Re: Question on Effective Java Item 27
- From: Andrew McDonagh
- Question on Effective Java Item 27
- Prev by Date: Re: UML Structured class with utility parts?
- Next by Date: Re: Proper state behavior? (was: Question on LSP)
- Previous by thread: Re: Question on Effective Java Item 27
- Next by thread: Re: Question on Effective Java Item 27
- Index(es):
Relevant Pages
|