Quote:
Originally Posted by gaming_mouse
the input is always known. the input is what's in the db. the output is something the application needs, like "Monday: 9am-1pm, 2pm-7pm...".
what i'm saying is that for any reasonable choice of structure in the db, the conversion to output such as the above is trivial. So it makes no sense to ask for the conversion function first.
Just a miscommunication?
By "unknown input" I mean "someone inserted some rows into the database. Now you need to turn that into human readable format"
I would argue that unless the format you are allowing the customer to enter is very strict and limited, you will have a hard time with this. That is, as I said, I think it would be easy to turn it into *a* human readable format, but probably not the one the customer wanted.
Imagine for example that the customer wants you to control his electronic sign. It will be green when the store is open and red when it's closed. It will also display the hours for the customer on the sign, like say it's an LCD display.
You make some fields for him to enter the hours. He is going to want to see THOSE hours printed on the sign, and he'll want it in green when they're open. Do you see how this would be a very hard ask with your chosen structure?
Another similar example would be, say, a cron file. Cron files are different in that instead of expressing ranges, they express times that things happen, but I could easily use the cron format to specify a set of open and close events. I could easily turn this into the suggested bitfield format.
I am saying that you could turn the bitfields back into a cron file. But I don't think you could universally turn them back into MY cron file, the one I gave you originally.
If you can't, then editing really becomes a pain in the ass, because instead of editing MY cron file now I get to edit what you think it should be.
I've run into this myself, as I said, with stock market opening hours. The system that I inherited stored them as a list of stopping and starting times in UTC. Everyone hated this, because it essentially lost the context that it was entered with (i.e. it lost the time zones, and it lost the expressive power of the syntax that was usable to enter the open times, which was cron-like)