one to many (passing variables)
Neil D. Cerutti
neilc at norwich.edu
Mon Jul 28 15:34:35 CEST 2014
On 7/25/2014 9:47 PM, C.D. Reimer wrote:
> Thank you for the link. I'm curious about one item mentioned in the
> article: "Avoid return values that Demand Exceptional Processing: return
> zero-length array or empty collection, not null"
> Isn't a zero-length array, empty collection and null all the same thing?
> Or does the "Demand Exceptional Processing" comes from testing to see if
> the object is empty versus being null?
This seems like a specific application of a more general rule (I think I
remember it from The C Programming Language by Kernighan and Ritchie):
Whenever possible, manage special cases with data rather than with code.
Doing so makes your data processing code simpler, and may help prevent
This should apply to any programming language.
A mundane example is managing multi-line street addresses in a system
storing addresses: most applications choose to store address lines as
Street Address 1, through Street Address N, for some finite value of N,
even though it results in special cases to handle. This is probably
because it is more efficient: non-normalised data can be an efficiency
win. Also, forgetting or refusing to handle the case of multi-line
street addresses works "well enough" most of the time.
You could instead store multi-line street addresses as a list of
components in the street address: Forgetting to handle the "special
cases" would then be impossible. In order to do a cheesy job you'd have
to explicitly retrieve street_address and ignore the rest.
More information about the Python-list