laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
There's always the TMTOWTDI principle, but allow me to point out a potential problem here:
Your checks are now position dependent. If you move a block of code around in the section that builds the byte string, causing the byte position to change, you'll be spending the next few days debugging. A more managable way to do this is with a bit field. By having each check toggle a bit on or off, you can now compare against a full value: Now, as long as you don't duplicate bit positions, you run into far less chances of fubar'ing the code should you insert tests, etc. But this really isn't the best way either, since the code that sets the bit position and the code that tests for it are separated, and use magic numbers. You should use constants, to make sure you mean the same thing in both places. There are a couple of good books that talk about how to prevent problems like this from creeping up on you. There is 'The Pragmatic Programmer', 'Code Complete', another good one whose name escapes me at the moment (it's on my bookshelf at home, and I'm not awake). --Chris In reply to (jcwren) RE: Building a byte to test truth table
by jcwren
|
|