Login  Register

Re: Lookup table, one or two?

Posted by Richard Sargent on Apr 13, 2016; 11:40pm
URL: https://forum.world.st/Lookup-table-one-or-two-tp4889780p4889798.html

On Wednesday, April 13, 2016 at 2:12:09 PM UTC-7, Louis LaBrunda wrote:
Hi All,

As a side project to our LibUSB project I'm working on some classes that will talk to an X10 CM19a USB transceiver.  You send commands to the CM19a and it passes them on to X10 devices and they turn on/off.  I have a lookup table of command objects keyed by a string like 'A-1-On'.  The command objects contain the same string and the hex codes (a ByteArray) to send to the CM19a.  So, given a command string, I can find the codes to send.

The CM19a can also tell that some other device (like a hand held remote) has sent the codes and I can read these codes.  I would like to look up the codes to know which command was sent.  I'm thinking of having a second lookup table keyed by the codes with the same command objects as values.

My question is, is it better (for what ever reason) to have two lookup tables or just one as the keys (strings and byte arrays) won't clash and it can all be in one table.

One table seems slightly easier but two seems cleaner.  So, what does everybody think?

I think the overhead to have a second table is insignificant. Unless there is a compelling argument to mix the two, go for clarity. That's always the rule for optimizations.
 

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.