Web application design question

F

Frank Moyles

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.
 
E

Eliyahu Goldin

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
 
R

Registered User

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?
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.
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.
 
V

vapor

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 said:
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 said:
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.
 
C

Coskun SUNALI [MVP]

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 said:
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 said:
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 said:
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.
 
A

Alvin Bruney [MVP]

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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top