Aug 6 2009

Know Thyself; Know Thy Team

Category: David @ 14:10

One of the most enjoyable aspects of being a Project Architect/Lead, and one which can sometimes be the source of frustration, is being part of a development team.  Any developer that has been part of a team knows that the production of a quality piece of software is affected by numerous factors, not the least of which is team dynamics. Part of being a leader in a team is not only understanding yourself, but also understanding the people on your team and the overall personality and dynamics of the team given the current members.

One of the tools that has been significant in helping me to understand myself, my strengths and weaknesses, has been the Jung/Myers-Briggs personality assessment.  (For those who have never heard of this before you can check it out here and take a quick online assessment hereto find out what your personality type is.)  It has shed light on some of my own behaviors as well as helped me to identify those areas that I struggle with and why I struggle to change in those areas.  As an INFP I have never felt a high level of excitement over administrative tasks.  That does not mean that I can’t develop adequate administrative skills, it just means that I am not going to develop a sense of fulfillment for that type of work nor will it be something that energizes me.  However, as an INFP I am a die hard idealist.  I love to discuss, expound and implement best practices in my software, but have also had to learn to inject myself with a good dose of realism on certain projects.

Understanding the personality types is beneficial in team dynamics and is two fold.  First you need to understand the personalities of each individual on your team. This is necessary so that you can better help them to develop in those areas where they are weak and also, to ensure that the majority of their time is spent on areas that are in alignment with their personality. This helps to ensure that they are energized by their work instead of drained by it.  As a general rule you want to make sure that the members of your team are working about 60-70% of the time in positions or on tasks that line up with their personality type.

For example, you will find that there are some personality types that are less likely to deviate from previously used practices and tend to work within those practices with great satisfaction, efficiency and high productivity.  This type of team member is a great “work horse” that can get a lot of work done as long as the parameters are defined for them and the direction is clear.  On the other hand, this is generally not the type of personality that you want to put on a task that requires a high level of creativity and thinking outside of the box.  Not that they can’t ever do that, but they will tend to not be as satisfied and energized by that work if it takes up the majority of their time.

Secondly, you not only need to understand the individual personalities on your team, but you also need to understand the overall personality of you team.  If you have a large number of Introverts on your team then you may need to focus more explicitly on communication within your team and with the other stake holders on your project.  If you have a high level of personality types with Judging as a strength you may find your team struggles to improvise under certain circumstances.  Ideally the analysis of your team should help you to adjust the makeup of your team (if possible) so that it is well balanced.

With this in mind here are a couple of questions to think about:

  1. Does a persons personality type affect their predisposition to a particular methodology for the Software Development Lifecycle?
  2. How does the overall personality of your team affect your teams success with a given SDL methodology?

Tags:

Aug 5 2009

Managing Session Variables in ASP.NET using a Proxy – Part 2

Category: .NET | Architecture | ASP.NET | Best Practices | Tips & TricksDavid @ 15:54

In my last post I gave an example of using the Proxy Design Pattern to manage your ASP.NET Session.  In this post I wanted to refine that proxy class through some refactoring and add some additional functionality to it that remove Session variables and also allow us to use the proxy to clear or abandon the Session as a whole. We will also create a mechanism for grouping Session variables into related objects in the SessionProxy.

First I want to add a private property that will allow me to eliminate some of the verbosity in my code.  I’ll add a private static property that encapsulates the current HTTPSessionState object.  We can then use that property to refactor our other properties so they are more readable.

   1: private static HttpSessionState Session { get { return HttpContext.Current.Session; } }

Next we’ll add some code into our properties that will check for the value being set and remove the Session variable from the Session object if necessary.  As an example I’ll use a new Property of type String.

   1: public static String CategoryName
   2: {
   3:    get 
   4:    {
   5:       if (Session[CATEGORYNAME] == null) { return String.Empty; }
   6:       return (String)Session[CATEGORYNAME];
   7:    }
   8:  
   9:    set 
  10:    {
  11:       if (String.IsNullOrEmpty(value)) { Session.Remove(CATEGORYNAME); }
  12:       else { Session[CATEGORYNAME] = value; }
  13:    }
  14: }

Now I want to add a few methods to allow me to use the SessionProxy to Clear the current Session or Abandon it.

   1: #region Methods
   2:  
   3: public static void Clear() { Session.Clear(); }
   4:      
   5: public static void Abandon() { Session.Abandon(); }
   6:      
   7: #endregion

At this point I feel that I have a pretty good proxy class that allows me to leverage my ASP.NET Session in a strongly type manner and to easily see what I am storing in the Session and what their types are.

However, in using this solution in a production application I have found that my list of properties has grown longer than I would like. There were close to two dozen at last count and all the Session variables have not been migrated to use the proxy.  I found myself increasingly tired of seeing all those properties each time I accessed the class.  On top of that some of the names were getting rather long in an effort to give them meaningful names.  To resolve this I implemented several properties on the SessionProxy that were child proxy objects.  To make things a bit easier I created a base class called SessionProxyChildProxyBase.  Here’s the code in full for that base class.

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Web;
   5: using System.Web.SessionState;
   6:  
   7: public abstract class SessionProxyChildProxyBase
   8: {
   9:  
  10:   #region Properties
  11:  
  12:   protected HttpSessionState Session { get { return HttpContext.Current.Session; } }
  13:  
  14:   #endregion
  15:  
  16: }

You will note a few points on this class.  Unlike the SessionProxy class the SessionProxyChildProxyBase class is an abstract class.  We don’t want to allow others to implement this base class outside of our library so that the SessionProxy class now becomes a proxy for this class as well as for the ASP.NET Session.  It also contains a protected Session property that will facilitate a decrease in code verbosity.

Now we will leverage this base class and create derived classes that will contain related properties.  In your application you may provide a central location for entering search criteria but you pass those criteria via the Session to a page that actually displays the search results.  Let’s create a child proxy class to organize the various values being passed.

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Web;
   5:  
   6: public class SearchSessionProxy: SessionProxyChildProxyBase
   7: {
   8:  
   9:   #region Fields
  10:  
  11:   private const String SEARCHTEXT = "SearchText";
  12:   private const String SEARCHTYPENAME = "SearchTypeName";
  13:   
  14:   #endregion
  15:  
  16:   #region Properties 
  17:  
  18:   public String Text
  19:   {
  20:      get
  21:      {
  22:         if (Session[SEARCHTEXT] == null) { return String.Empty; }
  23:         return (String)Session[SEARCHTEXT];
  24:      }
  25:  
  26:      set
  27:      {
  28:         if (String.IsNullOrEmpty(value)) { Session.Remove(SEARCHTEXT); }
  29:         else { Session[SEARCHTEXT] = value; }
  30:      }
  31:   }
  32:  
  33:   public String TypeName
  34:   {
  35:      get
  36:      {
  37:         if (Session[SEARCHTYPENAME] == null) { return String.Empty; }
  38:         return (String)Session[SEARCHTYPENAME];
  39:      }
  40:  
  41:      set
  42:      {
  43:         if (String.IsNullOrEmpty(value)) { Session.Remove(SEARCHTYPENAME); }
  44:         else { Session[SEARCHTYPENAME] = value; }
  45:      }
  46:   }
  47:  
  48:   #endregion
  49:  
  50:   #region Constructors
  51:  
  52:   internal SearchSessionProxy() { }
  53:  
  54:   #endregion
  55:  
  56: }

Now we need to add some code to our SessionProxy class to leverage this new class.  The first task is to add a private static field of type SearchSessionProxy.

   1: #region Fields
   2:  
   3: private static SearchSessionProxy _searchProxy = new SearchSessionProxy();
   4:  
   5: #endregion

Next we will create the property to access the field.

   1: public static SearchSessionProxy Search { get { return _searchProxy; } }

And that’s it!  Now we call utilize our SessionProxy with our new child proxy classes for organization and grouping so that we can doing something like this in our web app code…

   1: public void DoSomething() 
   2: {
   3:  SessionProxy.Search.Text = "Search Text entered by user";
   4:  SessionProxy.Search.TypeName = "Product Search";
   5:  SessionProxy.ProductID = 0;
   6:  Response.Redirect("SearchResults.aspx");
   7: }

Tags: , , , ,