Comment On Hmm .. where to place a button ...

Andrew Cain gives us the opportunity to peek at a remarkably bad UI from a behind-the-scenes perspective. While I can't say I've actually seen the web page for this code, I have a very strong feeling that we may in fact be looking at a web version of FileMatrix.  In addition to the concept of “interface design simplicity,“ the author seems completely forgotten about LOOP constructs to help with the 30+ grids ... [expand full text]
« PrevPage 1Next »

re: Hmm .. where to place a button ...

2004-07-07 14:19 • by ben
.NET made it "very hard" (i.e. not drag-n-drop'able [sarcasm]) to create control arrays... and, if you use control arrays it wipes out a lot of the WYSIWYG design features - which, with a grid control that's more complex than the space shuttle, is almost required unless you're http://www.datagridgirl.com :)

re: Hmm .. where to place a button ...

2004-07-07 14:23 • by Colin Angus Mackay
Also, you didn't mention the repeated lookups into the Session object - Surely it would have been more sensible to get the user_id out first, rather than look it up 30+ times for the page load and the button click.

re: Hmm .. where to place a button ...

2004-07-07 14:43 • by Alex Papadimoulis
ben,

For i = 1 to 30
Page.FindControl("Grid" & i).user_id = session("user_id")
Next

Too lazy to typecast, but it works with Explicit off.

re: Hmm .. where to place a button ...

2004-07-07 14:51 • by Tim Smith
Or just loop through all the controls and anything starting with "Grid" will have the user_id set. FindControl might be expensive. (Like calling "session ("user_id")" 5902390390 times isn't.) :)

re: Hmm .. where to place a button ...

2004-07-08 05:40 • by Paul Hill
Scream if you want to go faster...

dim GridSet as Grid() = {Grid1,Grid2 ....

...

dim UserID=Session("User_id")
for each GridItem as Grid in GridSet
GridItem.User_id=UserID
next

re: Hmm .. where to place a button ...

2004-07-08 09:05 • by Mario Goebbels
I barely coded anything in ASP.NET, so forgive me that stupid question, but does the Session object work like a FIFO list? I'm just trying to get the idea behind the second code snippet.

Because if you're passing Session("user_id") to SaveUserChoices, wouldn't each follow up call on the next grid overwrite the contents each time? Especially since the guy's applying to the same set of contents (Session("user_id")) to all grids in the first snippet.

I'm not supposed to get these two snippets, am I?

re: Hmm .. where to place a button ...

2004-07-08 09:34 • by Paul Hill
I'm guessing, but I think session("user_id") is storing a class that is a grab-bag,that these grid controls either stuff their state into (on SaveUserChoices) or grope around and get their stuff (on get). And yeah it's a horrible way to do this.

re: Hmm .. where to place a button ...

2004-07-08 13:42 • by Cablito
In the name of our good lord, what is wrong with that code?

Its very clear to read, anyone can understand, I mean, it is obvious he wants to store the user_id in all his grids.

He is probably just following company policies on writing clear and uneficient code.

I do that all the time, the more policies one can come up with, the less efficient code you write; you get what you ask for.

re: Hmm .. where to place a button ...

2004-07-08 19:02 • by Informer
He's been bumped to management since that code was written.

re: Hmm .. where to place a button ...

2004-07-14 12:04 • by Somebody
I work with at the place that put out that code, and the we think the guy that wrote it is one of the managers here....

re: Hmm .. where to place a button ...

2004-09-08 01:57 • by Chui Tey
Well, it may be company policy to review LOC productivity. Unwinding loops is a great way of doing it.

C++ pwns

2004-09-12 04:06 • by Todd Aspeotis
lol... vb

Re: re: Hmm .. where to place a button ...

2010-02-03 00:39 • by cbhacking (unregistered)
297898 in reply to 22618
Mario Goebbels:
I barely coded anything in ASP.NET, so forgive me that stupid question, but does the Session object work like a FIFO list? I'm just trying to get the idea behind the second code snippet.

Because if you're passing Session("user_id") to SaveUserChoices, wouldn't each follow up call on the next grid overwrite the contents each time? Especially since the guy's applying to the same set of contents (Session("user_id")) to all grids in the first snippet.

I'm not supposed to get these two snippets, am I?

Session(<index>) is a lookup function. In this case, it's using a String index, in the form Session("user_id"). The functionality is "Go to the Session object, look up the field called user_id, and return it".

The first snippet does this lookup 30-odd times, each time assigning it to a field of a Grid object.

The second snippet does the lookup another 30-odd times, and passes it as a parameter to each Grid object's SaveUserChoices function. It could be re-written as follows:
Dim id = Session("user_id")

GridX.SaveUserChoices(id)
« PrevPage 1Next »

Add Comment