I have a combo box that, when selected, displays text in 3 text boxes.
The combo box items are the 50 states, and the text boxes display information on state statutes. Right now I’m using a multidimensional array to hold the data for each state (each item in the array holds the state, item 1, item 2, item 3).
My question is: Would it be better or more compact to create a State data type that holds the 3 items, and actually if this is even an effective approach? I don’t like the array, it’s just all I know how to do right now.
For the most part, the 3 data types are used repeatedly.
For example, one of them is the time zone the state uses, so there are only 6 possible options.
I don’t have the code in front of me or I would post it, just something I was thinking about.
The question you have to ask yourself about a multidimensional array is, “Can another programmer look at it and understand what is going on?”
Is is more compact? Maybe mayby not. It all depends on the code. In truth, unless you are dealing with very low memory requirements, it probably doesn’t matter. Think of it this way, let’s say that each timezone takes up four bytes (size of an integer). Having entry for each timezone means you’ve used what 50 x 4 = 200 bytes. Not enough to worry about either way.
I would change it, because in 6 months you probably are going to have difficulty understanding what it does. Readability and maintainability is king in almost all situations.
so maybe an example is: