[Gambas-user] Weird, yet again. Two way access to a collection. (not really a gambas issue)

Bruce adamnt42 at gmail.com
Wed Nov 21 12:17:02 CET 2018



On 11/21/18 8:40 PM, Christof Thalhofer wrote:
> Am 21.11.18 um 09:54 schrieb Bruce:
> 
>> (EXAMPLE) Let's say we have an Ice Cream Parlor POS application that is
>> loosely connected to the inventory "system". If a situation occurs where
>> there is no chocolate ice cream in stock then, when the POS operator
>> presses key 4617 (a chocolate ice cream) then it would display
>> "Chocolate Ice Creams are out of stock today, offer another flavor". So,
>> code 1329 = that explanation, but when I'm coding I'd like to specify
>> the status as "NO_CHOC" rather than go search through a bunch of design
>> documents and other stuff to find the right status code to use.  I hope
>> that makes sense, it's the simplest explanation I can think of. By the
>> way, in reality we have around 1600 specific status codes in our
>> systems. So I am really hoping that someone has a good idea here.
> 
> Does the example describe a real situation? I mean, if the status
> represents the (non-)existence of a product in stock it is another thing
> as if the status represents the state of the code at runtime.
> 

Of course not, I just thought that people were sick of hearing about 
horse auctions.

> The first I would never handle by hardcoded status codes because once
> you invent a new product the software would have to be rewritten. That
> would be crazy in case of icecream.

And yes you are totally correct, the "explanations" have Subst 
parameters in them. So the "real" error mnemonic would be "NO_FLAVOUR" 
and the "POS" system would present the explanation "&1 Ice Creams are 
out of stock...", suitably adorned.

> 
> If the state of the software at runtime should be represented there are
> many possible solutions. For instance I could think about a combination
> of a bitmap together with integer constants.
> 
> A bitmap is like that
> 
> 0000101000101 ...
> 
> and can easily been stored in a string.
> 
> With constants you can set named positions in the bitmap, for example in
> a module named State:
> 
> Public Constant MachineRunnning as Integer = 1
> Public Constant OperatorFired as Integer = 2
> ...
> Public Constant MachineIsDirty as Integer = 5
> Public Constant OperatorDead as Integer = 6
> 
> In the Bitmap up there MachineIsDirty is set true and the operator lives ;-)
> 
> By writing code you now are able to write sth like:
> 
> State.Set(State.MachineIsDirty)
> 
> or
> 
> bMachineDirty = State.Get(State.MachineIsDirty)
> 
> As long as State.Set and State.Get translate the boolean value to
> bit-position and vice versa.
> 
> If you are interested, I dig the code for that (set and get values out
> of bitmaps) out of my libs.
> 

I like your general idea here. In fact, though, it's sort of how we are 
doing this currently.

A real, real example is this. We have an application that lets horse 
trainers submit a horse for an auction.  There are about 20 gazillion 
rules and regulations about the animal concerned, which we need to check 
in that application and several others before the horse is acceptable as 
as lot in that auction.  So we have a component that does all the 
necessary checking with the relevant authorities. If everything goes OK 
then the component can send back a result code of 400 ("Probity checks 
satisfied, proceed with submission"). Otherwise, it may send back a code 
of, say 463 ("This horse is registered with &1 as being deceased! Best 
of luck with trying to sell it") where &1 is replaced with the relevant 
authority name. The mnemonic in that case :-) might be "REG_HORSE_DEAD". 
Which is is hell of a lot easier to remember than 462, oops I meant 463, 
when maintaining the component code. If you get my drift.

> 
> 
> Alles Gute
> 
> Christof Thalhofer
> 
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 


And yes, the "products" change all the time. In this case they are the 
regulations that apply to validating an auctionable lot.  And yes, the 
*(%%&(^( authorities always pick the busiest time of the year to 
implement the rule changes! @#^%*#^*# !!!!

Sigh. I suppose I could just go back to two status codes: "OK" and 
"Computer says 'No'" but I don't think I'll get away with that. :-(

regards
b


More information about the User mailing list