Connecting Tech Pros Worldwide Forums | Help | Site Map

Web application design question

Frank Moyles
Guest
 
Posts: n/a
#1: Dec 23 '07
I am a developer with many years (approx 10years) development experience
using C++ for DESKTOP applications. I am writing a web application using
C#, and I wanted to ask a question about appropriate design.

My design is as follows:

I have an Application class, which delegates to various classes to
perform required functionality. The application class is responsible for
the following:


Authentication
Authorization
UserManagement
SystemAdmin

etc.


Because of the nature of the work that the Application class does, there
should not be more than one instance of it at any given time - since
both instances for example, may try to modify/save the same object to
database.

I was therefore thinking of implementing the Application class as a
Singleton. But then I rembered that a web application is different from
a desktop application, because you have several users requiring
authentication/authorisation etc at the same time - so maybe a Singleton
pattern would not be appropriate for web applications.

Even if I used a Singleton pattern - is the single instance restricted
to a particular users session - or does it apply server wide - i.e.
accross all sessions?

Any help and insight from experienced web application designers would be
much appreciated.

Eliyahu Goldin
Guest
 
Posts: n/a
#2: Dec 23 '07

re: Web application design question


Why don't you just use existing asp.net classes found in the
System.Web.Security namespace?

If you want to wrap them into your code, you can make a set of classes that
we handle all these aspects based on the existing classes, like
securityManager, userManager etc, and all your pages will use these classes.

If you want to share these classes between several applications, make them
in a separate project as a class library and include it to different
applications.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Frank Moyles" <fgmoyles@nospam.comwrote in message
news:L6ednYGsCrxb2_PaRVnyiQA@bt.com...
Quote:
>I am a developer with many years (approx 10years) development experience
>using C++ for DESKTOP applications. I am writing a web application using
>C#, and I wanted to ask a question about appropriate design.
>
My design is as follows:
>
I have an Application class, which delegates to various classes to perform
required functionality. The application class is responsible for the
following:
>
>
Authentication
Authorization
UserManagement
SystemAdmin
>
etc.
>
>
Because of the nature of the work that the Application class does, there
should not be more than one instance of it at any given time - since both
instances for example, may try to modify/save the same object to database.
>
I was therefore thinking of implementing the Application class as a
Singleton. But then I rembered that a web application is different from a
desktop application, because you have several users requiring
authentication/authorisation etc at the same time - so maybe a Singleton
pattern would not be appropriate for web applications.
>
Even if I used a Singleton pattern - is the single instance restricted to
a particular users session - or does it apply server wide - i.e. accross
all sessions?
>
Any help and insight from experienced web application designers would be
much appreciated.

Registered User
Guest
 
Posts: n/a
#3: Dec 23 '07

re: Web application design question


On Sun, 23 Dec 2007 11:27:49 +0000, Frank Moyles <fgmoyles@nospam.com>
wrote:
Quote:
>I am a developer with many years (approx 10years) development experience
>using C++ for DESKTOP applications. I am writing a web application using
>C#, and I wanted to ask a question about appropriate design.
>
>My design is as follows:
>
>I have an Application class, which delegates to various classes to
>perform required functionality. The application class is responsible for
>the following:
>
>
>Authentication
>Authorization
>UserManagement
>SystemAdmin
>
>etc.
>
Are these things your Application class does or things the web
application will have to do to support the Application class?
Quote:
>
>Because of the nature of the work that the Application class does, there
>should not be more than one instance of it at any given time - since
>both instances for example, may try to modify/save the same object to
>database.
>
>I was therefore thinking of implementing the Application class as a
>Singleton. But then I rembered that a web application is different from
>a desktop application, because you have several users requiring
>authentication/authorisation etc at the same time - so maybe a Singleton
>pattern would not be appropriate for web applications.
>
How does this work with the desktop application? It would seem that if
user A is running one instance of the app on box A and user B is also
running an instance on box B, concurrency issues might exist. With a
web application is both instances will run on box C. The
functionality's container isn't radically different in this respect.
Quote:
>Even if I used a Singleton pattern - is the single instance restricted
>to a particular users session - or does it apply server wide - i.e.
>accross all sessions?
>
>Any help and insight from experienced web application designers would be
>much appreciated.
Re-examine the desired core functionality and determine how/if it can
be used by multiple users at once. Any possible concurrency should be
handled within the application and not be limiting the application to
a single instance.

regards
A.G.
vapor
Guest
 
Posts: n/a
#4: Dec 24 '07

re: Web application design question


I agree here. In addition, Singletons on the web are exceedingly difficult
to create especially across a server farm - throw in web gardens and it
becomes an expensive approach.

--
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgwrote in
message news:ePLmhDWRIHA.4752@TK2MSFTNGP05.phx.gbl...
Quote:
Why don't you just use existing asp.net classes found in the
System.Web.Security namespace?
>
If you want to wrap them into your code, you can make a set of classes
that we handle all these aspects based on the existing classes, like
securityManager, userManager etc, and all your pages will use these
classes.
>
If you want to share these classes between several applications, make them
in a separate project as a class library and include it to different
applications.
>
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
>
>
"Frank Moyles" <fgmoyles@nospam.comwrote in message
news:L6ednYGsCrxb2_PaRVnyiQA@bt.com...
Quote:
>>I am a developer with many years (approx 10years) development experience
>>using C++ for DESKTOP applications. I am writing a web application using
>>C#, and I wanted to ask a question about appropriate design.
>>
>My design is as follows:
>>
>I have an Application class, which delegates to various classes to
>perform required functionality. The application class is responsible for
>the following:
>>
>>
>Authentication
>Authorization
>UserManagement
>SystemAdmin
>>
>etc.
>>
>>
>Because of the nature of the work that the Application class does, there
>should not be more than one instance of it at any given time - since both
>instances for example, may try to modify/save the same object to
>database.
>>
>I was therefore thinking of implementing the Application class as a
>Singleton. But then I rembered that a web application is different from a
>desktop application, because you have several users requiring
>authentication/authorisation etc at the same time - so maybe a Singleton
>pattern would not be appropriate for web applications.
>>
>Even if I used a Singleton pattern - is the single instance restricted to
>a particular users session - or does it apply server wide - i.e. accross
>all sessions?
>>
>Any help and insight from experienced web application designers would be
>much appreciated.
>
>
Coskun SUNALI [MVP]
Guest
 
Posts: n/a
#5: Dec 24 '07

re: Web application design question


Hi Frank,

First of all, I would like to say that I agree with both of other MVP
friends. With custom profile, custom membership and custom authorization
providers that either you can write or find on the web, you can easily get
over these kind of problems.

If you insist about using your own stuff within your Application class with
a Singleton architecture, I would like to suggest you reading about "lock"
feature in C#.

All the best,
Coskun SUNALI
MVP ASP/ASP.NET
http://sunali.com

"vapor" <vapordan@hotmail.comwrote in message
news:38ACFB4F-054E-4D62-AF05-58C35BBC7B61@microsoft.com...
Quote:
>I agree here. In addition, Singletons on the web are exceedingly difficult
>to create especially across a server farm - throw in web gardens and it
>becomes an expensive approach.
>
--
--
Regards,
Alvin Bruney [MVP ASP.NET]
>
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
>
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgwrote in
message news:ePLmhDWRIHA.4752@TK2MSFTNGP05.phx.gbl...
Quote:
>Why don't you just use existing asp.net classes found in the
>System.Web.Security namespace?
>>
>If you want to wrap them into your code, you can make a set of classes
>that we handle all these aspects based on the existing classes, like
>securityManager, userManager etc, and all your pages will use these
>classes.
>>
>If you want to share these classes between several applications, make
>them in a separate project as a class library and include it to different
>applications.
>>
>--
>Eliyahu Goldin,
>Software Developer
>Microsoft MVP [ASP.NET]
>http://msmvps.com/blogs/egoldin
>http://usableasp.net
>>
>>
>"Frank Moyles" <fgmoyles@nospam.comwrote in message
>news:L6ednYGsCrxb2_PaRVnyiQA@bt.com...
Quote:
>>>I am a developer with many years (approx 10years) development experience
>>>using C++ for DESKTOP applications. I am writing a web application using
>>>C#, and I wanted to ask a question about appropriate design.
>>>
>>My design is as follows:
>>>
>>I have an Application class, which delegates to various classes to
>>perform required functionality. The application class is responsible for
>>the following:
>>>
>>>
>>Authentication
>>Authorization
>>UserManagement
>>SystemAdmin
>>>
>>etc.
>>>
>>>
>>Because of the nature of the work that the Application class does, there
>>should not be more than one instance of it at any given time - since
>>both instances for example, may try to modify/save the same object to
>>database.
>>>
>>I was therefore thinking of implementing the Application class as a
>>Singleton. But then I rembered that a web application is different from
>>a desktop application, because you have several users requiring
>>authentication/authorisation etc at the same time - so maybe a Singleton
>>pattern would not be appropriate for web applications.
>>>
>>Even if I used a Singleton pattern - is the single instance restricted
>>to a particular users session - or does it apply server wide - i.e.
>>accross all sessions?
>>>
>>Any help and insight from experienced web application designers would be
>>much appreciated.
>>
>>
>
Alvin Bruney [MVP]
Guest
 
Posts: n/a
#6: Dec 31 '07

re: Web application design question


How does this work with the desktop application? It would seem that if
Quote:
user A is running one instance of the app on box A and user B is also
running an instance on box B, concurrency issues might exist.
Not usually. With a desktop app, concurrency is only an issue if the clients
hit a common back end source.

--
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

"Registered User" <n4jvp@ix.netcom.comwrote in message
news:l2nsm3l5r8c220p965qqa0gtp7iaqbne8i@4ax.com...
Quote:
On Sun, 23 Dec 2007 11:27:49 +0000, Frank Moyles <fgmoyles@nospam.com>
wrote:
>
Quote:
>>I am a developer with many years (approx 10years) development experience
>>using C++ for DESKTOP applications. I am writing a web application using
>>C#, and I wanted to ask a question about appropriate design.
>>
>>My design is as follows:
>>
>>I have an Application class, which delegates to various classes to
>>perform required functionality. The application class is responsible for
>>the following:
>>
>>
>>Authentication
>>Authorization
>>UserManagement
>>SystemAdmin
>>
>>etc.
>>
Are these things your Application class does or things the web
application will have to do to support the Application class?
Quote:
>>
>>Because of the nature of the work that the Application class does, there
>>should not be more than one instance of it at any given time - since
>>both instances for example, may try to modify/save the same object to
>>database.
>>
>>I was therefore thinking of implementing the Application class as a
>>Singleton. But then I rembered that a web application is different from
>>a desktop application, because you have several users requiring
>>authentication/authorisation etc at the same time - so maybe a Singleton
>>pattern would not be appropriate for web applications.
>>
How does this work with the desktop application? It would seem that if
user A is running one instance of the app on box A and user B is also
running an instance on box B, concurrency issues might exist. With a
web application is both instances will run on box C. The
functionality's container isn't radically different in this respect.
>
Quote:
>>Even if I used a Singleton pattern - is the single instance restricted
>>to a particular users session - or does it apply server wide - i.e.
>>accross all sessions?
>>
>>Any help and insight from experienced web application designers would be
>>much appreciated.
Re-examine the desired core functionality and determine how/if it can
be used by multiple users at once. Any possible concurrency should be
handled within the application and not be limiting the application to
a single instance.
>
regards
A.G.
Closed Thread