[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nyphp-talk
Subject:    Re: [nyphp-talk] Using greater than zero or multiplication?
From:       David Krings <ramons () gmx ! net>
Date:       2012-06-27 11:06:45
Message-ID: 4FEAE945.8030907 () gmx ! net
[Download RAW message or body]

On 6/27/2012 4:45 AM, Leam Hall wrote:
> Morning all!
>
> I'm working on my Tech Dive Planner and wanted to get a best practice idea
> from you. There are some calculations that need 3-5 variables set or the
> calculation isn't done. Since all the inputs are numeric and set to a default
> of zero, is it better to test each input to see if it's greater than zero or
> just multiply them once and see if the result is greater than zero?
>
> In the grand scheme of things there's no serious performance hit either way,
> the app is pretty small. I am trying to build my skills and good habits though.
>
> Thanks!
>
> Leam

Not that I am an expert in best practices, but I'd test each to be larger than 
zero. If you multiply them all you will only know that one of them is zero, 
but you do not know which one. How do you then report that to the user for 
corrections? OK, with five variables it should be somewhat easy for the user 
to figure out which one is 0 or missing, but what happens when your user is 
visually impaired? It will be a much bigger burden for them as they need to 
traverse each field. In short, test each of them and then craft a summary 
response that indicates wich entry / entries are zero and need correction.

David
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show-participation
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic