J
Jeremy Cowles
Hi all,
Disclaimer: This app is actually written in a different language, but I have
much respect for this group & wanted to get your input so please ignore any
minor syntactical errors.
I have a program that needs to perform an action: Inventory Adjustment.
This action takes several arguments:
Data to describe which item to adjust:
- Site
- Item
- Lot
- Serial #
The adjustment(s) to make:
- Quantity
- Expire Date
Goals: I have two user interfaces (Telnet/VT100 & Windows GUI), so I want to
use one set of validation code for both of them. Furthermore I don't want
any GUI code to be directly dependant on the DataAccess objects & methods.
So I was thinking this:
Class InventoryAdjustment
{
Private:
string site_id, item_id, lot, serial_no;
Public:
void setSite( site );
void setItem( item );
void setLot( lot );
void setSerial( serial );
void Adjust( qty, expire_dt );
};
So the validation functions look up the parameter, and throw an error if it
is not valid data, or save it for the Adjustment if it is valid: setSite(
site_id ) calls the data access object, which has a method bool
SiteIsValid(site_id), which in-turn runs the queries against our data.
Then, when Adjust( ) is called, it uses the stored data & the 2 input params
to perform the adjustment. I realize this approach is flawed, and that
perhaps something like this would be better:
Class Inventory
{
Public:
bool Adjust( site_id, item_id, lot, serial_no, qty, expire_dt );
// other actions to perform against inventory
}
But this doesn't provide any validation for the UI's. I guess I just need
some input, because I am starting to loose my mind. Am thinking too hard
about this?
TIA,
Jeremy
Disclaimer: This app is actually written in a different language, but I have
much respect for this group & wanted to get your input so please ignore any
minor syntactical errors.
I have a program that needs to perform an action: Inventory Adjustment.
This action takes several arguments:
Data to describe which item to adjust:
- Site
- Item
- Lot
- Serial #
The adjustment(s) to make:
- Quantity
- Expire Date
Goals: I have two user interfaces (Telnet/VT100 & Windows GUI), so I want to
use one set of validation code for both of them. Furthermore I don't want
any GUI code to be directly dependant on the DataAccess objects & methods.
So I was thinking this:
Class InventoryAdjustment
{
Private:
string site_id, item_id, lot, serial_no;
Public:
void setSite( site );
void setItem( item );
void setLot( lot );
void setSerial( serial );
void Adjust( qty, expire_dt );
};
So the validation functions look up the parameter, and throw an error if it
is not valid data, or save it for the Adjustment if it is valid: setSite(
site_id ) calls the data access object, which has a method bool
SiteIsValid(site_id), which in-turn runs the queries against our data.
Then, when Adjust( ) is called, it uses the stored data & the 2 input params
to perform the adjustment. I realize this approach is flawed, and that
perhaps something like this would be better:
Class Inventory
{
Public:
bool Adjust( site_id, item_id, lot, serial_no, qty, expire_dt );
// other actions to perform against inventory
}
But this doesn't provide any validation for the UI's. I guess I just need
some input, because I am starting to loose my mind. Am thinking too hard
about this?
TIA,
Jeremy