Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comment time...

Status
Not open for further replies.

gbaughma

IS-IT--Management
Staff member
Nov 21, 2003
4,772
US
So, I inherited a Point of Sale system, and the programmer did something that I'm of mixed opinion on. So...

What the programmer was doing was using the labels, gridviews, and so forth as variable storage.

So, instead of saying dSubTotal = 4.00, then setting lblSubTotal.Text = dSubTotal.ToString("F2"), he would instead do...

lblSubTotal.Text = "4.00", and then when he needed to, say, add the subtotal and the tax, he would do a lblTotal.Text = Val(lblSubTotal.Text) + Val(lblTax.Text)

... so he was using the labels as variable storage.

Now, I personally think that this is an incorrect way to do things (and yes, he'd use a gridview to store the individual items, etc. etc. etc...)

My personal opinion is that you keep all those values in a table or variables, and populate the screen from those variables... instead of keeping the values on the screen, then reading the screen back and converting to double, etc. etc.

What is your take on this?



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
There are two schools of thought:

1) Only store data once
This is what your coder is doing.
Adv: in a grid view, you don't need to extract the data to store it somewhere. If you need it, just get it from the graphic display.
Adv: Updates are easy
Dis: these are the most difficult objects to get data from
Dis: all the forms have to be created for the data and possibly hidden
Dis: data cannot be shared between forms
Dis: no tricks for large amounts of data

2) Keep data and GUI separate
This is probably what you and I are used to.
Adv: It is easy to abstract the data
Adv: Data can be shared between forms
Dis: Whenever the user updates the gui, the code has to keep the data in sync.

I've had lots of problems with case 1 so I normally stick to case 2.
 
  • Thread starter
  • Moderator
  • #3
Yeah... I tend to lean towards #2 myself... just old habits, pre-OOP programming.

Now I'm really good at OOP programming... I say it all the time...

... oh wait... that's "OOPs"

[rofl]


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
The other disadvantage of #2 is that some designs go too far. I once worked on a system that had 4 copies of the data: one in the database, one in an array, which was a map of the database, one for local storage for a form and one on the form itself. Unfortunately it was live and cast in stone so I just couldn't do anything about it. It was a really bad excuse for a fast computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top