Putting counters in names


September 13, 2022 by Kenneth Fisher

It’s not all that unusual, or unreasonable to put a counter in a name. For example let’s say you need multiple test instances for your Sales production instance. It’s not unreasonable to do something like this:

  • TestServer\Sales_Test1
  • TestServer\Sales_Test2

You do want to be somewhat careful though as it is possible you can get some very confusing names. For example let’s say that your production environment requires three different instances so you do something like this:

  • Sales_Prod1
  • Sales_Prod2
  • Sales_Prod3

But you also have two nodes for a cluster for an availability group. Now you have:

  • ProdServer_Node1\Sales1
  • ProdServer_Node1\Sales2
  • ProdServer_Node1\Sales3
  • ProdServer_Node2\Sales1
  • ProdServer_Node2\Sales2
  • ProdServer_Node2\Sales3

Your test environment doesn’t have a cluster, but you do have 2 copies of each of the instances, and since this server was upgraded recently your server team decided to create the new server with a counter (the original was something like TestServer01 and the new server is TestServer02).

  • TestServer02\Sales1_Test1
  • TestServer02\Sales2_Test1
  • TestServer02\Sales3_Test1
  • TestServer02\Sales1_Test2
  • TestServer02\Sales2_Test2
  • TestServer02\Sales3_Test2

If you think that’s starting to look a bit confusing you’re absolutely right. Now add in a case where they need a third set of test instances but TestServer02 is getting a bit overwhelmed so now you have TestServer03 with yet more instances on it.

The same thing can happen with variables. I’ve seen @Counter1, @Counter2, @Counter3, etc. in the same piece of code before.

In the end, while I don’t think it’s a problem to use a counter in a name, multiple counters can get bit confusing. So to keep the number of counters down I try to avoid them whenever I can come up with something else to use. This would have been a bit easier to follow in my ever so humble opinion.

  • TestServerWin2016\SalesWeb_Test1
  • TestServerWin2016\SalesDesign_Test1
  • TestServerWin2016\SalesApp_Test1
  • TestServerWin2016\SalesWeb_Test2
  • TestServerWin2016\SalesDesign_Test2
  • TestServerWin2016\SalesApp_Test2

Do I like having the windows version name in the server name? Not overly but I think it’s better than just a counter. And how do I feel about having more specific instance names? This is a 💯 for me. There’s not only no need to put a counter there now but the instance names are far more specific. It’s actually easy to tell what exactly this is intended for. And last but not least we have an actual counter. First test environment, second test environment. Perfect place for a counter and I can’t think of anything you could put there instead that would work better.

6 thoughts on “Putting counters in names

  1. dave wentzel says:

    There are only 2 hard problems in computing:
    1. naming conventions
    2. cache invalidation
    3. off-by-one errors

    Sometimes I dream of the good ol days when the quantity of servers was small due to capital expense and we named them something “cute” like: every server is named after a Disney character. So much easier to remember. This is why we give proper names to pets and children vs Child001.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: