Minor Namespace Feature

Namespaces in C# and packages in Java are a convenient method of keeping related classes together. If you want to use code in another package in java you need to import the classes. This means that two distinct namespaces are entirely unrelated.

I used to think that the C# namespaces worked in the same way.  However it seems that namespaces form a hiearchy.

Namespace A.B.C automatically has access to Namespaces A and A.B

This is a minor detail but is not that clearly stated in the tutorials that you normally get.  It is in the language guide but not as clearly stated as it could be. 

Real World Applications : Deployment and Upgrading

When an application is initially being developed life is relatively simple for the developer.  There is an application and there is a database.  You can tear down the database and rebuild it with impunity.

Once it has been deployed life gets a little more complex.  Databases require upgrade scripts.  You need to know which version of an app is on each users machine.

Life gets a little more complex once you have multiple deployment stages.  The simplest is the QA/Test database and the Production Database.  In almost all cases you want to script changes to the test database and only run the finished scripts against the production server (having backed it up first).  Personally I find it far easier to control a database if every seperate item is scripted in a one feature two script file basis: Create Constraint/Drop Constraint, Create Table/ Drop Table.  This works great for databases that you control directly.  This becomes hard when you don’t have control.

Recently I have been working on a workflow application (Team Track).  It is relativley painless to make chnages in the test environment.  The problem comes when you want to deploy those changes to production.  The migration tools do not migrate all of the options – the poor developer has to recreate everything by hand.  Server tools should be fully scriptable.  Developers need to think of how to partition their applications to cope with more complex production deployment stages.

MS Analysis Server 2000 also suffers this problem – you need to manually copy the changes from one server to another.  What were the developers doing when they left out scripting?

What I described is the simple case.  Oftern  there are more stages (QA, UAT, Staging, Pre-Live, Live).

Udf Oddities

I have been experiencing some wierd udf behaviour.
I have a udf that takes 7.5 mins to run.  The sql inside the udf runs in < 1s.
Run the query under index tuning wizard and it suggests a very odd index.
Adding the index gets the time for both down to < 1s.

I have a second udf that is not as condusive to the index tuning wizard.

 

Dynamic Type Loading

Here is a very simple sample of dynamic type loading:

==== LoadLibrary.cs ==== 

using System;
using System.Reflection;

namespace LoadLibrary
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly ass = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory
                + @”.SimpleLib.dll”);
            Type type = ass.GetType(“SimpleLib.SimpleClass”);
            object newInstance = Activator.CreateInstance(type);
            Console.WriteLine(newInstance);
            Console.ReadLine();
        }
    }
}

=== SimpleClass.cs ===

namespace SimpleLib
{
    public class SimpleClass
    {
        public override string ToString()
        {
            return “I am a simple class”;
        }
    }
}

 

Build simple class into SimpleLib.dll

Build LoadLibrary into LoadLibrary.exe

Put SimpleLib.dll into the same directory as LoadLibrary.