Ok I thank you guys for help. I now have a few things to chew on 8)
doser
@doser
Best posts made by doser
Latest posts made by doser
-
RE: 2 switch or not 2 switch?
-
RE: 2 switch or not 2 switch?
@Chris F said:
That also wouldn't be available if a user comes back to the page.
Try to stick with passing the values in the query string. Your
real state should be in the DB =).
Okay what about that problem:
U have a form on page1.aspx which needs info from page2.aspx.
You go onto that page make ur choice and come back to page1.aspx.
(was a requirement by the customer)
What u don't want is to reenter the values into the form fields of page1.aspx
. So with the querystring-method you would have to pass a big bunch of values
to page2.aspx which doesn't need a single one of them. Then you would
have to pass it back to page1.aspx along with the one value you chose on
page2.aspx. This wouldn't be very efficient coding, right?
-
RE: 2 switch or not 2 switch?
@Chris F said:
First of all, I wouldn't use session variables. If your user
bookmarks the display page and comes back later, it'll blow up.
Arbitrary limitations suck, and you have such a simple alternative.
which alternative would that be? page context?
-
RE: 2 switch or not 2 switch?
ok my example would be:
asp.net related:
page1.aspx has an option where the user can choose a datatype which is
then generated as a database field. this is given among other values to
page2.aspx which creates the result.
now on page2 you have 2 choices:
checking with switch statements which type the user has chosen or going
back to page1 and create an object which "knows" what to do if
(simplified here) i.e. the display() method of the data is
called. on page2.aspx you would just call display() on the object. but:
to do that you need to know how to cast the object - which class was
the one used to instatiate it - right? (cause page2.aspx only recieves
either a request-parameter or a session variable not knowing what type
it is.) this is usually done with reflection.
but somehow this feels a little overblown - maybe i'm wrong ? -
2 switch or not 2 switch?
hi, i read sometimes that it is "better" to use polymorphy and
reflection instead of switch statements. my question is: does it really
make sense to absolutely avoid switch statements? where would you draw
the line between the abstraction making sense and beeing overblown?
thx,
doser.