lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Soni L. once stated:
> On 31/08/16 10:35 PM, Sean Conner wrote:
> >It was thus said that the Great Sean Conner once stated:
> >>	attrib = 'title"
> >>	title  = 'This is the Title of this Object"
> >   Before Soni replies that will will give an error before taking some
> >moments to think about it, let me change the example a tiny bit:
> >
> >	attrib = 'title"
> >	title  = "This is the Title of this Object'
> >
> >	add_attribute(attrib,title)
> >
> >   And yes, mismatched quotes bite me quite often in Lua code.
> >
> >   -spc (Sigh---a bug in the sample bug)
> >
> >
> Assuming a proper add_attribute that doesn't accept nils (it really 
> shouldn't), you get a runtime error!

  I can't just let this go.  Sigh.

  Should a function called "add_attribute()" accept nils?  That's debatable. 
HTML 4 allowed for non-value attributes:

	<input type="checkbox" checked>

Or it could be that the usecase for this function is that an attribute that
is given a nil value should just quietly be ignored.  YOU DON'T KNOW! 
Especially since this is an example to show how mismatched quotes for
strings that can accept embedded newlines might not be a good idea.

  Three stories from work:  we process phone calls.  As a phone call is
being made, we get notification (via the phone network over SS7 and via the
Internet via SIP) that 505-555-1000 is calling 505-555-2000 [1].  It came to
pass that we were receiving notifications like 505-555-1000 is calling
505-555-1000.  This is something we were NOT expecting, and we weren't
handling it correctly (it was, in fact, really messing things up).  Turns
out that it's a valid case, and one we need to not do our thing---that case
is 505-555-1000 is checking voice mail.  Regardless of whether you (Soni)
think this is stupid or not, it is what it is.  It wasn't our call (pun
unintended) to say otherwise.

  Second story:  one of our components sends a special query to another
service (that returns a name for a given phone number---caller name ID)
every few seconds to ensure it's still up and running.  The reason for the
special query is that we don't get charged for it [2].  The unexpected
happened---the special query was removed from the service, so it kept
returning "record not found."  OUR code was a bit ... sloppy (let's say) in
checking the return code and the "record not found" was treated as "we never
heard back from the service, so it must be down."  That in turn caused our
component to shut down, which in turn caused other components to shut down
and pretty soon we weren't doing the job the Monopolistic Phone Companies
were paying us to do.  The original developer just assumed that this case,
the special query, would never be deleted.  Bad mistake on our part.

  Third story:  I'm writing code to parse SIP messages.  I have a bunch of
code to validate the message and return errors for certain problems---wrong
version of SIP, missing fields in required headers, etc.  My manager
override my concerns and forced me to ignore such errors as long as we could
proceed.  In most cases, yes, we could proceed but I didn't like the
decision.  At that point it wasn't my call.  I had to shup up and accept
potentially bad data.  

  Now the point of these three stores are---mistakes happen and we're not
always in control over everything.  Should add_attribute() error on nils? 
Maybe, maybe not.  Should add_attribute() reject an attribute named:

	title
     title  = "This is the Title of this Object

  Again, maybe, maybe not.  Depends on many factors, *some of which may be
out of my control*.

  Also, saying "[a]ssuming a proper add_attribute ..." is missing the point
*entirely*  It's a FUCKING EXAMPLE!  It shows a potential problem, and one
that, depending on how code *might* be written (and certainly not how you
demand code be written) could hide a bug for a long time.  How hard is that
to get through your skull?  There are times when something you think should
never happen (a phone calling itself) does.  There are times when you botch
the logic and bad things happen.  And there are times where you are forced
to do things you don't necessarily agree with (code wise).  

  That you continally *miss* the point is what is so frustrating in your
messages.

  -spc (Okay, now *plonk*)

[1]	In the North American Numbering Plan, any exchange of 555 is
	reserved for examples, much like 'example.net' and 'example.com' is
	reserved for examples.  These are not real phone numbers.

[2]	It's a very small charge, something on the order of a hundredth of a
	cent thereabouts, but it does add up.  Also, these are The
	Monopolistic Phone Companies we're talking about---they charge for
	*everything* coming or going.  This is yet another it is what it is.