473,378 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

N-tier and STATIC

I would like to be able to create a singleton when using my Error Handling
object. It uses a static Instance() method to return the currently
activated object. But my question is, since it is static, it is shared
between users on a web site? That I would not like since each user needs to
have their own instance. Does anyone know the behavior of an object that is
create and returned through a static method with ASP.NET? If the Singleton
pattern does make it global to the application, how are other people
handling object instanciation when the object should be shared between tiers
but not between users of the application?

Reference material:
http://msdn.microsoft.com/library/de...tondespatt.asp
Nov 18 '05 #1
7 1528
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uB**************@TK2MSFTNGP11.phx.gbl...
I would like to be able to create a singleton when using my Error Handling
object. It uses a static Instance() method to return the currently
activated object. But my question is, since it is static, it is shared
between users on a web site? That I would not like since each user needs to have their own instance. Does anyone know the behavior of an object that is create and returned through a static method with ASP.NET? If the Singleton pattern does make it global to the application, how are other people
handling object instanciation when the object should be shared between tiers but not between users of the application?

Reference material:

http://msdn.microsoft.com/library/de...tondespatt.asp

static objects are shared between users. This has nothing to do with whether
or not the object is returned from a static method. It has to do with
whether or not the object is declared static.

If you need something per-user, you need to use Session variables.

You talk about sharing between tiers. Are these tiers meant to be in
separate processes or AppDomains? If so, you will need to use .NET Remoting
to share between AppDomains. Session state won't work.

Does your Error handling object need to maintain state?
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
The Error object does keep a state, in that it increments a count when an
other error is added to it. It also holds the error messages and exposes
properties to get the Count and Message.

Right now, I'm instantiating the object in my Page Base class. This class
is inherited by all ASP pages. This works pretty well for the pages. But
when I create my business object, I'm passing the Error handling object to
the business layer thru the constructor. I'd like to be able to eliminate
that passing.

Also on my UserControls, I have to expose a property where the page can pass
the error handling object to it. If I forget to do that, then there are
problems, so I'd like to eliminate that as well. I'm not quite caught up on
all of the details in OOP and don't have a firm grasp of the patterns and in
what cases they should be used yet.

Andrea
"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl...
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uB**************@TK2MSFTNGP11.phx.gbl...
I would like to be able to create a singleton when using my Error Handling object. It uses a static Instance() method to return the currently
activated object. But my question is, since it is static, it is shared
between users on a web site? That I would not like since each user
needs to
have their own instance. Does anyone know the behavior of an object
that is
create and returned through a static method with ASP.NET? If the Singleton
pattern does make it global to the application, how are other people
handling object instanciation when the object should be shared between

tiers
but not between users of the application?

Reference material:

http://msdn.microsoft.com/library/de...tondespatt.asp
static objects are shared between users. This has nothing to do with whether or not the object is returned from a static method. It has to do with
whether or not the object is declared static.

If you need something per-user, you need to use Session variables.

You talk about sharing between tiers. Are these tiers meant to be in
separate processes or AppDomains? If so, you will need to use .NET Remoting to share between AppDomains. Session state won't work.

Does your Error handling object need to maintain state?
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #3
you can use the HttpContext.Current.Cache for this. it caches objects for
the life of the request, and will available to any 3 tier objects called
directly from the page.
-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uK*************@TK2MSFTNGP12.phx.gbl...
The Error object does keep a state, in that it increments a count when an
other error is added to it. It also holds the error messages and exposes
properties to get the Count and Message.

Right now, I'm instantiating the object in my Page Base class. This class
is inherited by all ASP pages. This works pretty well for the pages. But
when I create my business object, I'm passing the Error handling object to
the business layer thru the constructor. I'd like to be able to eliminate
that passing.

Also on my UserControls, I have to expose a property where the page can pass the error handling object to it. If I forget to do that, then there are
problems, so I'd like to eliminate that as well. I'm not quite caught up on all of the details in OOP and don't have a firm grasp of the patterns and in what cases they should be used yet.

Andrea
"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl...
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uB**************@TK2MSFTNGP11.phx.gbl...
I would like to be able to create a singleton when using my Error Handling object. It uses a static Instance() method to return the currently
activated object. But my question is, since it is static, it is shared between users on a web site? That I would not like since each user needs
to
have their own instance. Does anyone know the behavior of an object

that
is
create and returned through a static method with ASP.NET? If the

Singleton
pattern does make it global to the application, how are other people
handling object instanciation when the object should be shared between

tiers
but not between users of the application?

Reference material:

http://msdn.microsoft.com/library/de...tondespatt.asp
static objects are shared between users. This has nothing to do with

whether
or not the object is returned from a static method. It has to do with
whether or not the object is declared static.

If you need something per-user, you need to use Session variables.

You talk about sharing between tiers. Are these tiers meant to be in
separate processes or AppDomains? If so, you will need to use .NET

Remoting
to share between AppDomains. Session state won't work.

Does your Error handling object need to maintain state?
--
John Saunders
johnwsaundersiii at hotmail


Nov 18 '05 #4

"bruce barker" <no***********@safeco.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
you can use the HttpContext.Current.Cache for this. it caches objects for
the life of the request, and will available to any 3 tier objects called
directly from the page.


No, as far as I know (and we use it as such), the Cache is application wide,
and the lifetime is not limited to a single request!

But, you can access the Session through HttpContext.Current.Session
(if there IS a current httpcontext, which is not the case on session-end,
for instance)

Hans Kesting
Nov 18 '05 #5
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uK*************@TK2MSFTNGP12.phx.gbl...
The Error object does keep a state, in that it increments a count when an
other error is added to it. It also holds the error messages and exposes
properties to get the Count and Message.


You can store the Error object in Session state (e.g., Session["Error"]). It
can be created in Global.asax, in the PreRequestHandlerExecute event, if it
doesn't already exist. Both user controls and pages will be able to
reference it as Session["Error"].

In cases like this, I prefer to create a public property in Global.asax:

public ErrorClass Error
{
get
{
if (Session["Error"] == null)
{
Session["Error"] = new ErrorClass();
}

return (ErrorClass) Session["Error"];
}
}

This can then be referenced as Global.Error.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #6
Thanks for the suggestion, but I forgot to mention that we are staying away
from session state. It's a shared system and we don't want to be forced to
go to a dedicated box.

Any other ideas?

Andrea
"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:ew**************@TK2MSFTNGP09.phx.gbl...
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uK*************@TK2MSFTNGP12.phx.gbl...
The Error object does keep a state, in that it increments a count when an other error is added to it. It also holds the error messages and exposes properties to get the Count and Message.
You can store the Error object in Session state (e.g., Session["Error"]).

It can be created in Global.asax, in the PreRequestHandlerExecute event, if it doesn't already exist. Both user controls and pages will be able to
reference it as Session["Error"].

In cases like this, I prefer to create a public property in Global.asax:

public ErrorClass Error
{
get
{
if (Session["Error"] == null)
{
Session["Error"] = new ErrorClass();
}

return (ErrorClass) Session["Error"];
}
}

This can then be referenced as Global.Error.
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #7
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Thanks for the suggestion, but I forgot to mention that we are staying away from session state. It's a shared system and we don't want to be forced to go to a dedicated box.
Session state shouldn't force you to a dedicated box. Also, keep in mind
that most of the problems which Session state had in ASP are fixed in
ASP.NET.
--
John Saunders
johnwsaundersiii at hotmail

"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:ew**************@TK2MSFTNGP09.phx.gbl...
"Andrea Williams" <an*******@hotmailIHATESPAM.com> wrote in message
news:uK*************@TK2MSFTNGP12.phx.gbl...
The Error object does keep a state, in that it increments a count when an other error is added to it. It also holds the error messages and exposes properties to get the Count and Message.
You can store the Error object in Session state (e.g.,

Session["Error"]). It
can be created in Global.asax, in the PreRequestHandlerExecute event, if

it
doesn't already exist. Both user controls and pages will be able to
reference it as Session["Error"].

In cases like this, I prefer to create a public property in Global.asax:

public ErrorClass Error
{
get
{
if (Session["Error"] == null)
{
Session["Error"] = new ErrorClass();
}

return (ErrorClass) Session["Error"];
}
}

This can then be referenced as Global.Error.
--
John Saunders
johnwsaundersiii at hotmail


Nov 18 '05 #8

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

Similar topics

0
by: tstephan | last post by:
In the past we have used the classic nTier design with COM+, SQL Server and MFC. We are currently working on a new project with an opportunity to use .NET, ADO.NET, etc. One of the areas where I...
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
5
by: Ryan Ternier | last post by:
I know how this should be done in regards to nTier, but it seems a bit inneficient, and was wondering if there's a solution that I havn't thought of yet. (I'm switching this loop to For Each Row...
1
by: Dnx | last post by:
hi i'm a very beginner of visual studio .net 2003 and aspx/vb.net i have to create a project with an architecture ntier i understand the concept but in practical, i don't know where to begin... ...
2
by: Åženol Akbulak | last post by:
Hi; I am developing an 3 tiered application. And my user interface is an ASP.NET web application. My methods in BLL only uses own parameters and DAL. Now my methods are not static. I heard that...
0
by: Jon Vaughan | last post by:
Hello, I have an NTIER Model written in VB.NET, at the moment is running as a client / server. Pushing a pulling data from the client to the server is fine and is done via webservice calls. But...
0
by: Jon Vaughan | last post by:
Hello, I have an NTIER Model written in VB.NET, at the moment is running as a client / server. Pushing a pulling data from the client to the server is fine and is done via webservice calls. But...
0
by: acnx | last post by:
I have an ntier application. I am trying to determine what is the best practice for handing errors in a datagrid. My datagrids are able to add, update and delete data. I am using a...
14
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared...
0
by: fra | last post by:
Ciao a tutti, è disponibile on line un esempio completo di progetto NTier da usare come base per lo sviluppo di una web application strutturata?? Intendo un esempio con gestione corretta dei vari...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.