Re: Question on Effective Java Item 27



"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


.



Relevant Pages

  • Re: Decoding strategy
    ... Mapping is actually two-step process, ... address at which to map the file, this isn't necessary, nor does it to my ... needs physical RAM that's not available). ... This doesn't reserve any ...
    (microsoft.public.dotnet.languages.csharp)
  • behavior as mapping
    ... seeing behavior as a mapping from a very high dimension ... that the map has been changed. ... The brain has a finite and relatively fixed number of neurons, ... But in fact, before we learned how to ride a bike, ...
    (comp.ai.philosophy)
  • Re: Binary Tree and Pairs of Nodes
    ... Every node in your infinite binary tree occurs at the ... So you say you have a mapping of every path to a node. ... You do not map My path to 1, because whichEVER path YOU mapped to 1, ...
    (sci.logic)
  • Re: MVC - Model binding to collection
    ... If you use ViewPage, you have a more explicit way of defining your model so you can drill through more explicitly. ... I am creating the view without problem, but my expectation is that I can create a textbox with a name which will enable the defaultmodelbinder to map back the post variables to the model. ... I'm sure that my model could be a little simpler, although I would still have Contact Data as a collection and it is complicated a little because of the linqtosql mapping. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Decoding strategy
    ... Mapping is actually two-step process, ... address at which to map the file, this isn't necessary, nor does it to my ... needs physical RAM that's not available). ... There are reasons that you might not be able to map an entire file into your ...
    (microsoft.public.dotnet.languages.csharp)