Session Facade Vs Singleton Object Design Patterns?

Mar 27, 2010

which one is better in "Session Facade Class" and "Singleton Object" design patterns in ASP.Net? Also, please state the scenarions where specific design pattern is advisable to use.

View 1 Replies


Similar Messages:

Design Patterns - Singleton Behavior With Multi-user Requests In C#?

Jan 7, 2011

I need to create a singleton that would hold lots of data for a spedesign patterns - Singleton behavior with multi-user requests in ASP.NETcific user. However, I am not unclear as to what the behavior of that singleton is in regard to multi-user app requests.

Here is the scenario:

On AppStart event I want to load common data for all users (from SQL) and store it as a collection somewhere within the ASP.NET storage mechanisms.

If I store that data in the cache, I would also have to create a static property in the Global.asax that would provide access to that the data from the cache.

This is not ideal because whenever an instance of any particular page, or generic handler, or what have you tries to query this data using Linq the property has to load the data from the cache... introducing latency. I need this data to be immediately available. (think of it as about 5K rows of data stored in collection of objects...)

I was thinking to use a singleton to get that data, and store it but I don't know how it would behave between requests (and postbacks), as well as application instances, in terms of its persistence.

On PostAuthenticate event I want to get user specific data from SQL in the form of a collection. If i store it as a singleton (in a similar manner as the common data) i am not clear as to:

How is the data persisted? What is the scope of that singleton (it should be for the duration of the user session). How can I ensure that the data is immediately available to whatever needs to consume it?
What happens between post-backs to that singleton? If another user logs in would another instance of that singleton be created for that specific application instance?

View 1 Replies

Architecture :: Design Patterns Vs Architectural Patterns

Jan 10, 2011

1.what is the difference between design patterns vs architectural patterns ?

2. In which situations They are preffered?

View 2 Replies

Design Patterns & UML Diagrams?

Apr 27, 2010

what are design patterns and UML diagrams with best examples. How we should use in real time scenarios. Recurring iam facing these type of questions in project round.

View 5 Replies

Session Object Design Pattern?

Jan 28, 2011

I'm looking to build an ajax page; it's a reporting page. By default, load today's report. On the page there's a calendar control and when the user clicks on a date, reload the gridview with the corresponding data. Is it considered good practice to do the following:

1) on the first page load, query the data for the page

2) put the query result in the session object and display it in a gridview

3) if the user requests new data, get new data from the query with different parameters

4) put the result of the second query in the session object and display it

5) if the user then requests the data from the first query, get it from the session object

6) do the sorting and paging with the data held in the session.

Note: the data of each query will contain about 300-500 rows and about 15 columns. I'd like to do all this with ajax calls. What are some suggestions and pitfalls to avoid.

View 4 Replies

Web Forms :: Want To Use Design Patterns In .net Application?

May 17, 2010

I'm trying to build a small, web application. But I want to use desing patterns in it. So I have a question: which desing patterns do you use and why in asp.net applications?

View 11 Replies

Which Of The Two Design Patterns Should I Implement In A 3-tier .Net Application

Sep 22, 2010

I'm trying to decide which of the two factory patterns I should use in my Asp.Net applications:

1 : All DAL providers derive from same abstract base class DepartmentsProvider, which defines public interface of the class ( all the necessary CRUD methods for which derived classes (providers ) provide a concrete implementation ). BLL layer instantiates correct provider by calling DepartmentsProvider.Instance:

public abstract class DepartmentsProvider
{
static private DepartmentsProvider _instance = null;
/// <summary>[code]....

In first case we implement new provider by deriving from DepartmentsProvider class, while in second case new provider is implemented by deriving from DBProviderFactory. What are pros and cons of each implementation?

View 1 Replies

Architecture :: Design Patterns For Handling User Web Navigation And Flow?

Jan 20, 2011

Our site is expected to allow the user to do whatever they want from a number of different places. Except, that doing whatever they want really means firing off mini sequences of pages they must vist (or possibly abort from to go off to another task) before returning to their starting point. So, at any given time, the user has a list of pages they are allowed to go to, a list of pages they must go to in order to complete their task, and some end point they must eventually return to, all of which are constantly changing.

As an example, a user may choose to edit an order they placed, at which point they must step through a series of pages to edit the order. These pages to edit an order may be different based on the type of order they are editing, and they must return to whatever place they were at when they decided to start editing the order. They may also have certain options of other pages to visit during their order editing process.

I really need a good way to handle this for a large number of different scenarios, and allow it to be easily changed. Right now we are doing things like setting session variables when a user chooses an action and checking them within the page on button handlers to see what they are allowed to do or where they are allowed to go. I'd love to be able to abstract this out into something that can be easily examined in one place, or even data driven, and have some sort of navigation controller pointing them to the pages they can or must go.

View 6 Replies

Web Forms :: Difference Between Singleton Design Pattern And Static Methods

May 7, 2015

In one of the interview, I was asked why should we have to go for Single Design pattern, instead of just creating static methods. Because creating static methods also serve the same purpose, i.;e avoiding flooding of objects.

View 1 Replies

Singleton Object In IIS Web Garden?

May 23, 2010

I have a lot of Singleton implementation in asp.net application and want to move my application to IIS Web Garden environment for some performance reasons.

CMIIW, moving to IIS Web Garden with n worker process, there will be one singleton object created in each worker process, which make it not a single object anymore because n > 1.

can I make all those singleton objects, singleton again in IIS Web Garden?

View 1 Replies

C# - Creating Web Service Singleton Object

Dec 1, 2010

I am creating a singleton object in the first request to the web service and keeping it in the memory. This works fine for first few seconds. If I make a request 5 minutes later, I can see that the singleton object is created again? is my singleton object getting disposed after x no of minutes? how can i make increase the life-time of my object forever ?

public sealed class Singleton
{
static ServerInstance instance = null;
static readonly object padlock = new object();
Singleton() {
}
public static ServerInstance Instance {
get {
lock (padlock) {
if (instance == null) {
instance = new ServerInstance();
}
return instance;
}
}
}
~Singleton()
{
#if DEBUG
ExceptionFactory.Fatal("~Singleton() called!");
#endif
}
}
[WebMethod]
public string OnReceiveEvent(string objectXmlData, string objectType) {
if (!Singleton.Instance.initServerComplete) {
InitServer();
}
return Singleton.Instance.OnReceiveEvent(objectXmlData, objectType);
}
public void InitServer() {
if (!Singleton.Instance.initServerComplete) {
Singleton.Instance.InitServer();
Singleton.Instance.initServerComplete = true;
GC.KeepAlive(Singleton.Instance);
}
}

View 2 Replies

C# - Session Vs Singleton Pattern?

May 12, 2010

I have a web application where I would like to pull user settings from a database and store them for Global access. Would it make more sense to store the data in a Singleton, or a Session object? What's the difference between the two?Is it better to store the data as an object reference or break it up into value type objects (ints and strings)?

View 3 Replies

Vb.net - Singleton IN Per Session Or Per Machine?

Sep 8, 2010

I have an web application written in ASP.NET (FW 3.5) (along with some VBScript, this is a legacy app) that uses a utility class in the backend that logs error. I need to log several values that a user has entered in the front-end. Since the utility class has no access to the front end (or any HTTP services), i created a singleton class within the utility namespace that my front end UI can access and store information about the user.

I guess more specifically, I am wondering if there's a way to store session variables that can be shared across the web application and web services through a class referenced by both of the application and web services. For example, I have an error handling class that is used by both instances that required information about the user. Is there a way to create a per-session singleton to hold that information, so that my error class will have access to the user info? or is this not possible - that i'll need to pass the information around as they are needed?

View 1 Replies

State Management :: Why Singleton Returns Same Object In Stateless Environment

Jun 2, 2010

If I run below ASP.NET code, it gives me same output in different post-backs. First Time

Name is = Smith
also After Post-back (Button Click)
Name is = Smith

I feel though I have defined singleton, it should return a new object every time in different ASP.NET post-backs. because once the function "PAGE_LOAD" is completed then there are no reference variables holding singleton object. So there is a change of unloading the singleton class from memory by CLR. that means there is a chance of losing private static reference variable and also single ton object stored. In ASP.NET stateless environment, why is it keeping earlier object in multiple post backs and btw, without having any reference variable to that object. Is this is known danger with singleton in ASP.NET environment?

[Code]....

View 4 Replies

DataSource Controls :: Make ObjectDataSource Typename Of A Singleton Business Object?

Mar 14, 2010

How do I make ObjectDataSource work with singleton Business object? My singleton business object is defined in Global:

[Code]....

I get an error:The type specified in the TypeName property of ObjectDataSource 'objThreads' could not be found.

View 2 Replies

WCF / ASMX :: Singleton Object - Leave Business / Data Layers In Main Solution

Jan 13, 2011

I have an ASP.NET 4.0 site that I expect to come under extremely high volumes in the next month or so and I am attempting to maximize performance. The site is divided into the front end UI pages, as was as a business and data layer. My thought was to pull the business and data layer out and wrap them in a NamedPipes Connected Windows Service running in Singleton mode.

I created the windows service, got the connection setup correctly and now I am wondering if this is just asking for trouble. Is this a good idea or should I just leave the Business/Data layers in the main solution and let IIS spin those objects up and down for each request? In essence I was thinking that using a WCF Windows Service as an Application Server would be more efficient but that is just a theory

View 1 Replies

Architecture :: Architecture And Design Patterns?

Mar 16, 2011

hat is the difference between Architecture and Design patterns ?

View 8 Replies

Architecture :: Looking For Better Way To Design, To Use Object's Properties With The Object Data Source?

May 10, 2010

I've posted the same question in the Object Data Source forum. This is a link to it http://forums.asp.net/t/1554083.aspx. Maybe I should've posted here to begin with. There seemed to be some overlap so I wasn't sure which was the best on to post the question in.

I'm trying to get a better understanding of how I could've designed my app so that the Object Data Source could work with the properties of my business objects. Please read the other post to see how it's currently being done. Sorry for the link to the other page. I didn't want to post a bunch of duplicate information. I would love to get some suggestions for alternative ways of doing this.

View 1 Replies

C# - Store Class Properties In Session And Use Of Session Handler - Is It Good Design

Jul 27, 2010

I have a class called EditMapUtilities. Here are some class properties that I want to persist:

public class EditMapUtlities
{
public static Boolean isInitialEditMapPageLoad
{
get { return SessionHandler.isInitialEditMapPageLoad; }
set { SessionHandler.isInitialEditMapPageLoad = value; }
}
// REST OF CLASS NOT GERMAIN TO DISCUSSION AND OMITTED
}

Here is my SessionHandler Class following the pattern from this post Static Session Class and Multiple Users:
using System.Web.SessionState;

public static class SessionHandler
{
private static HttpSessionState currentSession
{
get
{
if (HttpContext.Current.Session == null)
throw new Exception("Session is not available in the current context.");
else
return HttpContext.Current.Session;
}
}
//A boolean type session variable
private static string _isInitialEditMapPageLoad = "EditMapInitialPageLoad";
public static bool isInitialEditMapPageLoad
{
get
{
if (currentSession[_isInitialEditMapPageLoad] == null)
return true;
else
return (Boolean)currentSession[_isInitialEditMapPageLoad];
}
set
{
currentSession[_isInitialEditMapPageLoad] = value;
}
}
}

I am still learning OOAD. I want to keep relevant properties with relevant classes. I also want to keep all Session stored variables in one place for ease of maintenance and to encapsulate the session keys and calls. I feel like my design is too coupled though. How can I make it more loosely coupled? Is my editMapUtilities class too tightly coupled to the SessionHandler class? How would you do it better?

View 2 Replies

Web Forms :: Session Ended - But Server Error/ Object Reference Not Set To An Instance Of Object?

Nov 15, 2010

In the VS2005 environment, when I test my session to make sure the page redirects to the main page (itself) if the session is null, it works. There is no error.

The function I use for this is:

[code]....

However, when it is in the production environment in IIS 6.0, when the session has timed out, and I then do a postback by doing some slider control, I see the page reload but immediately thereafter, it throws a Server Error exception of : Object reference not set to an instance of object.

Looking at the stack trace, the event occured:

AJAXEnabledWebApplication1._Default.Slider1_TextChanged(Object sender, EventArgs e)

however, why is it that the Slider1_TextChanged event fired even even after during page_load, the page was told to do a response.direct ?? shouldn't the entire page have gone through a full-page refresh life cycle ? why did it continue on to attempt to raise the Slider1_TextChanged event?

View 1 Replies

Web Forms :: Error When Converting Session To String / Object Reference Not Set To Instance Of Object

May 7, 2015

I am getting object refernce error at line:if (Session["Tax"].ToString() == "9")

protected void Page_Load(object sender, EventArgs e)
{
if (Session["Tax"].ToString() == "9")
{
lblTax.Text = Session["Tax"].ToString();
}
else
{
lblTax.Text = "0";
}
}

Is anything wrong I have done?

View 1 Replies

Facade Pattern For Asp.net Mvc Application

Feb 16, 2011

I have an MVC2 application with the following classes:

-OrderModel
-LineOrderModel
-OrderController
-LineOrderController

In the OrderController class I'm recollecting some values of a web form . Until now, I created instances of each order line (LineOrderModel class) and OrderClass inside of the Controller.

I was trying to create a OrderFacade class in order to encapsulate the different things to do when creating an order.

So in that class I created a method like this:

public void saveOrder(int idProvider,decimal? price)
{
// Here I create instances of OrderModel and LineOrderModel
// and assign their properties
}

but my problem is I don't know how to pass all the order lines captured from the web form.

I think it doesn't make sense to create and pass to that method a List with orderLines class (because the point of this is to operate with the Facade, not with the class directly)

How could I encapsulate the different lines (all with properties like numberUnits,idProduct ...) into a List of generic objects, each one with these properties?

Maybe something like a List<List<object>> ?

View 1 Replies

Create A Copy Of An Object In Session To Update Without Updating Session?

Jul 20, 2010

I am confused about how to reference objects in session, how to update, and copy.

if I create
MyObject obj = new Object ();
then
Session["object"] = obj;
MyObject temp = (MyObject)Session["object"];

If i change something on temp, will the object in session be updated? do i need to follow changes with Session["object"] = temp?

View 2 Replies

State Management :: How To Manage Session Data Outside The Session Object

Oct 7, 2010

I want to be able to persist data across a session but do this outside of the built-in session state object. Why is a long story that I will not go into here. I just need to know where I can put data other than in the session object that will persist across the specific session.

View 3 Replies

Resolve Url In Facade Or Controller Class

Jan 28, 2010

I have a facade class that my controller class calls out to and in that facade class, for whatever reason, I'm building a string a href element. And it resolves fine in casini but when it gets out in the real world like localhost it doesn't work. Is there a way to do this?

string goBackLinkForErrorMessage = "<br /><a href='/MyController/Action?id=" + blah + "'>Go Back</a>";

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved