[nycphp-talk] All In the Game of PHP
Peter Sawczynec
ps at sun-code.com
Wed Jun 13 12:05:42 EDT 2007
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. That is, programming logic error
examples, such as:
You expect users to weigh platinum by the pound;
someone will try to weigh chicken necks by the ounce.
You expect users to pay in Dollars, Punds, Yen, Franc, Lire and Marks;
someone will try to pay in Real.
You expect users to pick a State;
they live in Canada and need Provinces.
You expect 5-digit numerical Zip;
UK users have 6-char alpha/numeric mixed.
You execute a cart in English, Japanese and Spanish;
a user is visually impaired and speaks native Dutch.
You build online tech support live chat 8AM-8PM EST;
only to find 23% of users log in from Eastern Europe in off hours.
Every function you write, every tool you develop has to be prepared to
accept and deal with wrong information or input out of your expected
bounds.
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
When tighter functions and logic need to be fashioned like so:
if
dollars do this
elseif
yen do this
elseif
marks do this
elseif
pounds do this
else
unknown currency raise user error flag
end if
This one precuationary step alone will CYA so many times you may appear
teflon.
Warmest regards,
Peter Sawczynec
Technology Dir.
Sun-code.com
Web related services
646.316.3678
ps at sun-code.com
More information about the talk
mailing list