Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
Voted to close as off-topic, this belongs on stackoverflow.com –  fmark Jul 28 '10 at 2:01
add comment

closed as off topic by fmark, Rowland Shaw, mwalker, scw, Richard Morgan Jul 29 '10 at 1:01

Questions on Geographic Information Systems Stack Exchange are expected to relate to geographic information systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

It seems your question is independent of GIS specifically, so StackOverflow might be a better place to look for some guidance. One particular question there discusses best practices with ASP.NET Session: http://stackoverflow.com/questions/133236/asp-net-session

If all else fails, try posting this (or a variation) there.

share|improve this answer
    
Voting to close as off-topic is the correct response here. –  fmark Jul 28 '10 at 2:00
    
+1 to the close but if you are using Session to store client display state the OP may want to head away from Session and move that logic to client side JavaScript. –  Dandy Jul 28 '10 at 13:36
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.