NYCPHP Meetup

NYPHP.org

[nycphp-talk] All In the Game of PHP

David Krings ramons at gmx.net
Wed Jun 13 14:49:19 EDT 2007


Peter Sawczynec wrote:
> The number one muck up I have observed in coding, is programmers
> creating functions or tools that leave off the final "else" clause at
> the 
> end of a conditional logic tree. 

True! Bit me in the behind before where I was staring at a blank page in 
the browser not knowing why.

> 
> You expect users to weigh platinum by the pound;  
> someone will try to weigh chicken necks by the ounce.

Or in general, uses metric. "23" can be anything and if not made clear 
it might as well drill your multimillion $ space probe straight into 
Mars. Honestly, Americans with their "English" system don't deserve 
better. ;)

> You expect users to pay in Dollars, Punds, Yen, Franc, Lire and Marks;  
> someone will try to pay in Real.
See above, depends on which Franc you are talking about. And even worse, 
French Franc, Italian Lira, and German Marks don't exist anymore.

> You expect 5-digit numerical Zip;  
> UK users have 6-char alpha/numeric mixed.
I dove into this some time ago and there are about a dozen standardized 
means of writing an address. I think I have that code somewhere to 
handle this. That covers at least the majority of cases, but for sure 
not all.

> You execute a cart in English, Japanese and Spanish;  
> a user is visually impaired and speaks native Dutch. 
Or is German and has an attidue like Simon Cowell.

> Incomplete function logic tree I have seen many times: 
> 
> if 
>   dollars do this 
> elseif
>   yen do this 
> elseif
>   marks do this 
> else 
>   pounds do this
> end if 
> 
> This one precuationary step alone will CYA so many times you may appear
> teflon.
> 

Or use switch, case, and default, which supposedly is the better 
approach since the Logo days.

David




More information about the talk mailing list