473,804 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Static Class Factory - Alice is seeing Bob's data

Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.G etProfile(Guid
userID) which will take the user's GUID as an input and return me the Profile
memento class for use in interface. The memento class has no real
functionality, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types. Where I
would expect to see the first user's (Alice) image and data, I see Alice's
image with Bob's data in it. I know it isn't Bob's image because he has a
different type of image. The request to class factory with Alice's Guid has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?
Oct 11 '07 #1
6 1639
Static data are shared accross the whole application domain. As a web site
is a single application, it means that static data are shared accross all
users. This is mot often the problem (you still can use static properties as
long as the underlying storage is not shared).

--
Patrice

"ri***@newsgrou ps.nospam" <ri************ *******@discuss ions.microsoft. com>
a écrit dans le message de news:
2C************* *************** **...icrosof t.com...
Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running
atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.G etProfile(Guid
userID) which will take the user's GUID as an input and return me the
Profile
memento class for use in interface. The memento class has no real
functionality, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types. Where
I
would expect to see the first user's (Alice) image and data, I see Alice's
image with Bob's data in it. I know it isn't Bob's image because he has
a
different type of image. The request to class factory with Alice's Guid
has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?

Oct 11 '07 #2
You may want to check http://support.microsoft.com/kb/893666/en-us for
details.

"Patrice" <http://www.chez.com/scribe/a écrit dans le message de news:
up************* *@TK2MSFTNGP04. phx.gbl...
Static data are shared accross the whole application domain. As a web site
is a single application, it means that static data are shared accross all
users. This is mot often the problem (you still can use static properties
as long as the underlying storage is not shared).

--
Patrice

"ri***@newsgrou ps.nospam"
<ri************ *******@discuss ions.microsoft. coma écrit dans le message
de news: 2C************* *************** **...icrosof t.com...
>Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running
atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into
a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.G etProfile(Guid
userID) which will take the user's GUID as an input and return me the
Profile
memento class for use in interface. The memento class has no real
functionalit y, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types.
Where I
would expect to see the first user's (Alice) image and data, I see
Alice's
image with Bob's data in it. I know it isn't Bob's image because he has
a
different type of image. The request to class factory with Alice's Guid
has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?


Oct 11 '07 #3
"ri***@newsgrou ps.nospam" <ri************ *******@discuss ions.microsoft. com>
wrote in message news:2C******** *************** ***********@mic rosoft.com...
Have I royally messed up my architecture here?
Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #4
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
"ri***@newsgrou ps.nospam" <ri************ *******@discuss ions.microsoft. com>
wrote in message news:2C******** *************** ***********@mic rosoft.com...
Have I royally messed up my architecture here?

Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #5
you are confusing static methods with static objects. your factory
sample is a static method. this method is thread/session safe as long as
it and all of the method calls made do not use a static object. In your
case one of them must (there must be code that looks like you first
example).

-- bruce (sqlwork.com)
ri***@newsgroup s.nospam wrote:
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
>"ri***@newsgro ups.nospam" <ri************ *******@discuss ions.microsoft. com>
wrote in message news:2C******** *************** ***********@mic rosoft.com...
>>Have I royally messed up my architecture here?
Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #6
This is not necessarily in this class. You'll have to check for input and
output values (if the argument or the result is at some point stored in a
static value it could cause the same problem). You could have also the same
problem somewhere in your "get data" code.

--
Patrice

"ri***@newsgrou ps.nospam" <ri************ *******@discuss ions.microsoft. com>
a écrit dans le message de news:
B1************* *************** **...icrosof t.com...
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values
e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
>"ri***@newsgro ups.nospam"
<ri*********** ********@discus sions.microsoft .com>
wrote in message
news:2C******* *************** ************@mi crosoft.com...
Have I royally messed up my architecture here?

Static variables in ASP.NET need *extremely* careful management because
they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Oct 11 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8036
by: Neil Zanella | last post by:
Hello, I would like to know whether it is possible to define static class methods and data members in Python (similar to the way it can be done in C++ or Java). These do not seem to be mentioned in "Learning Python" by Mark Lutz and David Ascher. It seems like they are a relatively new feature... It seems to me that any truly OO programming language should support these so I'm sure that Python is no exception, but how can these be...
15
64140
by: DBA | last post by:
Hi All, What is the diff. between a singleton class and a static class in C#?
2
5486
by: Vivek Ragunathan | last post by:
Hi Are the members in a static class in C# class synchronized for multiple thread access. If yes, are all static members in a C# class auto synchronized ? Regards Vivek Ragunathan
7
2400
by: Jon Vaughan | last post by:
I have a piece of code that I want to run on a Pocket Pc, I have written a data class that will store the small amount of data that is required for the program. As this class will be used via a few forms in the program, what the best way to setup this class - Static ? and if so where do I enter the setup for the initial fetch, as at the moment its in the constructor, i'm right in thinking there is no constructor in a static class. Thanks
1
9452
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create my SQL connection in the code-behind, I get the following error. I tried to register the DLL using regsvr32 but that errored out saying, "dllregisterserver entry point was not found". Any ideas? Retrieving the COM class factory...
8
8934
by: Per Bull Holmen | last post by:
Hey Im new to c++, so bear with me. I'm used to other OO languages, where it is possible to have class-level initialization functions, that initialize the CLASS rather than an instance of it. Like, for instance the Objective-C method: +(void)initialize Which has the following characteristics: It is guaranteed to be run
2
1673
by: titan.nyquist | last post by:
I need to initialize data to be stored in a static class (for all my code to see), but I'm lost on how to do so. If I use the class constructor, what if it fails? I am reading it information from files that (could potentially) not exist. If it throws an exception, it could be thrown wherever the first access to the class is, which is undetermined. This seems like a bad idea. Furthurmore, the data initialization code should be run at...
9
5051
by: Zytan | last post by:
"A static member 'function' cannot be marked as override, virtual or abstract" Is it possible to make a static class member function (which is also static, obviously) that is an override to ToString()? Maybe it makes no sense to do such a thing... Zytan
49
5815
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current name search scope. i.e. a very simple application would be class ManyComputations { calling System.Math;
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.