473,474 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Create 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.GetProfile(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 1618
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***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
a écrit dans le message de news:
2C**********************************@microsoft.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.GetProfile(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***@newsgroups.nospam"
<ri*******************@discussions.microsoft.com a écrit dans le message
de news: 2C**********************************@microsoft.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.GetProfile(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 #3
"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.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***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.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***@newsgroups.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***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.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***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
a écrit dans le message de news:
B1**********************************@microsoft.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***@newsgroups.nospam"
<ri*******************@discussions.microsoft.co m>
wrote in message
news:2C**********************************@microso ft.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
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...
15
by: DBA | last post by:
Hi All, What is the diff. between a singleton class and a static class in C#?
2
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
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...
1
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...
8
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....
2
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...
9
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...
49
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.