In yesterday's post (Bitten by the Enterprise Bug), we learned how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things. Today, I'd like to dig into the code of enterprise systems a bit.

Today's example was actually submitted by a few different people over a span of a couple months and is from the data-access layer of an enterprise .NET application. For you non-enterprise developers, here's an easy way to make your applications more enterprisey: add lots and lots of constants.

If you're looking at today's code and thinking, gee, shouldn't these be in stored procedures, or views, or something, then you're still thinking in the world of unenterpriseness. Remember, the enterprisocity of an application is directly proportionate to the number of constants defined ...

public class SqlWords
  public const string SELECT = " SELECT ";
  public const string TOP = " TOP ";
  public const string DISTINCT = " DISTINCT ";
  public const string FROM = " FROM ";
  public const string INNER = " INNER ";
  public const string JOIN = " JOIN ";
  public const string INNER_JOIN = " INNER JOIN ";
  public const string LEFT = " LEFT ";
  /* SNIP */

  public const string ORDER_BY = " ORDER BY ";
  public const string ASC = " ASC ";
  public const string DESC = " DESC ";

public class SqlQueries
  public const string SELECT_ACTIVE_PRODCUTS = 
    SqlWords.SELECT + 
    SqlWords.STAR + 
    SqlWords.FROM + 
    SqlTables.PRODUCTS +
    SqlWords.WHERE + 
    SqlWords.EQUALS + 

  /* SNIP */

  public const string UPDATE_LOGON = 
    SqlWords.UPDATE +
    SqlTables.CREDENTIALS +
    SqlWords.SET +
    SqlWords.EQUALS + 
    SqlMisc.PARAMS_FIRST + 
    SqlWords.COMMA +
    SqlWords.EQUALS + 

... I should note that this approach also pads your code against changes in the SQL language. I've heard from some good sources that the next version of SQL will use the word "GIMMIE" instead of "SELECT".

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!