Last post Feb 23, 2012 10:07 PM by atconway
Feb 23, 2012 11:10 AM|steventnorris|LINK
I've seen a couple of ideas on this. Classes that house variables. Static classes with static variables using a Singleton-like structure. What are the methods and pros/cons? I'm looking to use some site-wide variables soon, but haven't given it a go yet.
Feb 23, 2012 11:16 AM|adamturner34|LINK
What scope do you mean by site wide? Session scope? Application Scope?
Do the variables only need to be available in RAM or do you need to store them?
Feb 23, 2012 11:25 AM|steventnorris|LINK
Application scope. These will be stored dictionaries, lists, and other tools used to identify mappings between SQL data and the visible representation as well as site-wide static data. I'm thinking of going with a singleton structure. It feels very smooth
and right, but I want to know the different ideas, pros, and cons out there first.
Feb 23, 2012 11:28 AM|SGWellens|LINK
Perhaps caching would fulfill your requirements:
Feb 23, 2012 11:43 AM|adamturner34|LINK
If you're going to be analyzing this data, I would suggest writing it either to XML or store it in the database.
Feb 23, 2012 11:53 AM|steventnorris|LINK
SGWellens: That's an interesting feature I didn't know about. That would work great for some of the more static database pulls I'll be doing. I think the dictionaries and such would benefit from a application level instantiation. They may not be used often,
but when they are used, I'd like them already created and sitting ready. (Although, giving it some thought cacheing with a large enough time dependency would render pretty much the same outcome for most all users).
AdamTurner34: This isn't so much data analysis as it is data pairing. For example, my SQL row headers were not created by me and do not have a user friendly form. I want a dictionary to map the SQL headers with the display text so I can fluidly grab that.
I don't want to recreate the dictionary for this on each page, so application scoped. The cacheing would work well for the xml/database data on a whole though.
Feb 23, 2012 10:07 PM|atconway|LINK
This isn't so much data analysis as it is data pairing. For example, my SQL row headers were not created by me and do not have a user friendly form. I want a dictionary to map the SQL headers with the display text so I can fluidly grab that.
Hopefully I am wrong here but other than the static lists, etc (which the suggestion for Application Caching is a great one and he one I recommend as well), you are not inferring that you want some type of global dictionary mapping of SQL values to global
variables are you? I hope I am wrong here because I used to see that in VB6 where these huge monolithic modules were used to create global varibales that represented their SQL data equivilent and they were nasty. For example a SQL value of "CustomerLastName"
might be "gFld_CustomerLastName". Global scope and so easy to step on the toes of varibales because no encapsulation of behavior or data was used via individual classes.
If for some reason what I described above is indeed what you want then I strongly recommend a different approach. This is the responsibility of the data model being mapped to the object model. Typically this happens low in the lowest layers of the
application, and in return values are exposed via Properties on classes. Or use something like EF and this is doen for you already. Weather a busniess object, DTO, or something else, the values are never just represented by some gloal variable with no relationship
to anything else all on its own.