RE: FN-FORUM: JavaScript help....
date posted 6th August 2003 17:30
Dom wrote:
> If you're using Booleans and they're not independent, your analysis
> is broken. Take two variables, A & B. If for instance A is always
> true when B is true, you've encoded a four-state system, when there
> are only three states. If A cannot be true when B is true, the same.
>
> In this case, there's a 64 state system (six Booleans) to encode a
> three state system (the bit that switches docObj and styleObj three
> ways - IE4, NS4, none of the above).
>
> At first sight this seems rather perverse, hence my question, why
> Booleans?
>
> In fact, why not just use the provided appName and appVersion to do
> what you want? I.e.
>
> // pseudo-code
> switch name
> case navigator
> if version >=4
> do stuff
> else if version >3
> do other stuff
> case Eskimo
This prevents you from doing stuff like:
if ie4 do stuff
If we stuck to your suggestion we'd have to do something like this instead:
if !navigator && version == 4 do stuff
I know which I'd prefer. So what if you're declaring more variables than
you strictly need? It's not as if your computer is going to have trouble
keeping track of six variables instead of two!
You've also got a more extensible model - the one you suggested breaks down
if you want to distinguish between three different browser types.
--
[EMAIL REMOVED]
DJSE Limited, Willow End, Mawthorpe, Alford, Lincolnshire, LN13 9LT
T: 01507 466 797
F: 01507 463 731
M: 07970 801 661
http://www.djse.com
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.507 / Virus Database: 304 - Release Date: 04/08/2003