# Thursday, June 21, 2007

How not to handle storing database connection string information

// if we don't find the connection string in session state, assume that we
// need to initialize all session variables
if (this.Session["connect_comersus"] == null)
{
    this.Session.Add("connect_comersus", (string) strConnect);
}

How not to get the current assembly version for a web app, here's the relevant appSetting:

<add key="dll_path" value="\\CorpWebServer\WebAppROOT$\Secure\bin\Company.CorpSite.Secure.dll" />

Here's the code that reads the version:

        private string GetBuildText()
        {
            string strPath = null,
                strVersion = null,
                strDate = null,
                strReturn = null;
            FileInfo fiMain = null;
            Assembly objMain = null;

            strPath = ConfigurationSettings.AppSettings["dll_path"];
            fiMain = new FileInfo(strPath);
            if (fiMain.Exists)
            {
                objMain = Assembly.LoadFrom(strPath);

                strDate = fiMain.LastWriteTime.ToString("ddMMMyyy HH:mm");
                strVersion = objMain.GetName().Version.ToString();

                strReturn = strVersion + " &diams; " + strDate;
            }
            else strReturn = String.Empty;

            return strReturn;
        }

There are many more, but that's enough for right now.




WTF
Thursday, June 21, 2007 9:25:18 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, June 20, 2007

The “empire” cares more about political prestige than it cares or knows about technology.  The empire is setup structurally to create infighting and to stifle team work.  This is done to create the illusion of potential progress but it really just ends with a circle of finger pointing.

The empire is clearly run by a bunch of bureaucrats whose aim is to pacify the masses with bloated software factories.  Why software factories, complicated frameworks, and RAD generated goo?

  1. Claimed reuse.  By spending a ton of money on a platform we ensure support and reduce costs by reducing redundancy.  In reality we end up with an overpriced and bloated platform that only gets us 80% of what we need.
  2. Feature bullet points.  This supposedly makes the customer feel warm and fuzzy because there are a lot of out of the box features.  In reality most of these bells and whistles will never be used; and to top it these features lock us in to the platform.
  3. It makes the empire look professional.  In reality the empire chose the software factory because they really know nothing about software development.  By having a bunch of useless code on the table it gives them something to talk about and hide behind in their endless meetings.
  4. Mort can understand it.  Maybe Mort can run the wizard to generate more goo, but what happens when you run into some nasty threading bug on your web server?  Do you just start over? 

The empire assumes the worst of developers; they believe developers are a bunch of lazy interchangeable Morts or parts.  They pander to the lowest common denominator because of high turn over and the inability to attract real engineers who are not only good, but passionate about software development. 

In effect, the empire doesn’t know the difference between a programming God and a Mort.  Even if a God did manage to sneak into their ranks they would surely be stifled by the systems the empire has put into place to protect itself.  The empire stays safe by locking everything down so that nothing moves; the theme here is to avoid risk at all costs (option 1, do nothing).

Therein lies the root cause of evil within the empire, they almost always choose to do nothing because it’s safer, but it’s safer because their alternative to “do nothing” is the “all or nothing” approach.  They choose all or nothing largely because their process and their software is incapable of adapting, once it has shipped its set in stone. 

The calcified software is only mimicking the inflexible process laid down by the empire’s inner PM sanctum*.  Besides the PM’s living and breathing waterfall, the real tragedy is the funding model.  The funding model wants the exact cost of the completed system up front, well before any design, let alone coding has started.  This funding model tied to an arbitrary deadline gets the customer some software, but as it often turns out its not the software the customer needs or wants.  The end goal is not about satisfying the customer or improving the process, the end goal is to stay within budget and to check all the boxes.

With the project complete (according to the Gantt chart) the empire moves on to yet another project to replace the new legacy system just completed, and the circle of software creationalism start anew.

 

* Interestingly enough the empire’s PM methodology is called Atlas after the great iterative submarine ballistic missile program from the late 1950’s and early 1960’s.  The real interesting part of this is that the empire’s methodology is pure waterfall, and is nothing like the Atlas missile program.  In fact some of the stupid PERT calculations used during that program were bogus and only used to satisfy the bureaucrats.

Other | WTF
Wednesday, June 20, 2007 7:08:27 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, June 19, 2007

While setting up a C++ static shared library under Linux and unit testing under C++ for the first time, I found the following resources useful.  Unit testing in C++ does leave me wanting runtime reflection quite a bit, but I think CxxUnit's approach is quite workable despite the fact that the GUI runner sucks.

GNU Make user guide: http://www.gnu.org/software/make/manual/make.pdf

Static Lib Tutorial: http://www.iram.fr/~roche/code/c++/c++_AddNumbers.html

CxxTest user guide: http://cxxtest.sourceforge.net/guide.pdf



Tuesday, June 19, 2007 3:45:14 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
# Wednesday, June 13, 2007
Here's a really interesting way to conduct unit tests using in memory collections with LINQ: http://iancooper.spaces.live.com/blog/cns%21844BD2811F9ABE9C%21397.entry

I'll need this in the future me thinks...

Wednesday, June 13, 2007 5:08:28 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, June 05, 2007
I was so used to using the Java Seralizable interface for arguments, that I kind of miss it in a way in .NET.  In fact I missed being able to easily tell if an object was serializable, but someone pointed this out to me today:

[Serializable]
public class User
{
...
}


if (typeof(new User()).IsSerializable)
   Console.WriteLine("The User type is serializable");



Tuesday, June 05, 2007 6:08:44 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, June 01, 2007
Found this in a comment on ScottGu's blog:

We use the web setup project to deploy our web applications. To automate additional installation tasks like setting the .NET version and encrypting the web.config files we use a custom installer along with the web setup project (see relevant code below). However we recently ran into a problem when deploying an application on a server where there are several web sites. The site we wanted to install on was not the default site. Therefore our code to set the .NET version and assign the newly created application pool did not work since "W3SVC/1/ROOT/" was not the correct path to the website. Is there a property similar to [TARGETDIR] which we can pass to our custom installer to account for this. We know hard-coding "W3SVC/1/ROOT/" was not the best option but we also knew it would be correct 90% of the time. Thanks as always for your time.

Best Regards,

Stephen

info = New ProcessStartInfo()

info.FileName = "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe"

info.Arguments = String.Format("-s W3SVC/1/ROOT/" & strVDir)

info.CreateNoWindow = True

info.UseShellExecute = False

Process.Start(info)

info = Nothing

Dim myApp As New DirectoryEntry("IIS://localhost/W3SVC/1/ROOT/" & strVDir)

myApp.Properties("AppPoolId").Item(0) = strMyAppPoolName

myApp.CommitChanges()

myApp = Nothing

# re: Using IIS with VS 2005 and the new Web Project system

Friday, January 12, 2007 2:00 AM by ScottGu

Hi Stephen,

You can pass in the targetsite and targetvdir path as context parameters to your custom action by passing this:

/targetdir="[TARGETDIR]\" /targetvdir="[TARGETVDIR]" /targetsite="[TARGETSITE]"

Friday, June 01, 2007 10:11:13 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
I upgraded a web service application from .NET 1.1 and was getting the following error:

Parser error global.asax could not load type

I found this was caused because the installer for the application was creating an IIS web application set to use .NET 1.1.

Friday, June 01, 2007 9:46:32 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

Warning, this is a bit of a rant…

Today I was trying to add a new unit test project to one of our solutions through the Visual Studio VSS plugin.  Everything seemed fine until I realized I had named the project folder incorrectly.  I thought “no big deal” I’ll just rename the project folder, but of course there is no way to do this through Visual Studio, you have to remove the project, rename the folder through Explorer, then re-add the project.  But since this was already checked in I would need to go through the VSS client and rename the project folder.  That’s why I hate source control integration with Visual Studio, it doesn’t support all scenarios (especially renaming things correctly to preserve history) and it tends to add an extra layer of complexity.  In addition to renaming the folder I needed to edit the solution to point to the correct location.  The one problem was that I forgot to change the stupid source control bindings so when you went to open the solution it wouldn’t find the project.  Apparently I needed to “rebind” the project – at this point I just hand edited the sln file to rebind it to the proper location.  After that everything seemed to be OK.

Just to make sure, I decided to open up my SourceOffsite client (SourceOffsite is basically a 3rd party client/server product to allow access to SS over TCP/IP) to verify things would look OK to the remote devs; but where’s the stuff I just checked in?  After some searching through the SOS forums I found out I needed to “Refresh Project Tree.”  That showed me the new files, but now I noticed the versions were incorrect.  I then had to get latest and overwrite local changes (even though I already had the latest) to update SOS on my client.  So now I have three possible points of contact with the source control database, and they seem to all have their own view of what’s going on.  This just scares the hell out of me, and makes integration painful.  Integration should be easy!  After all, we want everyone to integrate their changes as quickly as possible.

As per our current team rules, I then needed to send an email to everyone with a list of my changes.  Of course SS doesn’t have change lists so I have no way to know what the hell I just checked in.  We also don’t have a CC.NET server yet, so I couldn’t check there either.  Argh!

What a bunch of crap.  Something that should have taken me 10 minutes took me over an hour.  I think its time to setup an internal Subversion server to show everyone the way towards the light.

Friday, June 01, 2007 7:09:22 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, May 24, 2007
I had forgotten how much I hate dealing with web projects in Visual Studio 2003, until today.  I went to open up one of our companies VS 2003 web projects and didn't have a virtual directory configured before hand, so when it tried to open it complained it couldn't find the path to the csproj file.  OK, no big deal, open up inetmgr and create a virtual directory.  Well that was a good though, except I entered the incorrect path for the virtual directory.  Try again, change the virtual directory to the correct path and try an open the project again.  No good, I get this error now, "Unable to get the project file from the web server."  What the?

The fix: delete *.* from c:\documents and settings\sneal\VSWebCache.

Thursday, May 24, 2007 6:01:56 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
# Friday, May 18, 2007
I moved my little demo application (aka FoodBankTracker) that I use for demoing tech over to Visual Studio 2007 / .NET 3.5 today without much hassle.  The only real hassle I had was with log4net version/strong key mismatches between MonoRail RC2 and NHibernate 1.2 GA, but that's entirely another story.  The main reason I wanted to move it over to the new platform was to really try out the new language integrated queries (LINQ).  I ended up using the LINQ -> NHibernate criteria adapter being maintained by Ayende for several reasons:
  1. My NHibernate mapping files are complete.
  2. I like the unit of work NHibernate provides.
  3. Its always good to have some abstraction between the domain and the database layer.
  4. I'm familiar with NHibernate and already have infrastructure in place for it.
I grabbed the latest code from subversion for the LINQ -> NHibernate adapter and was up and running in no time.  The only change I had to make was to upgrade the NHibernate version from 1.2 beta3 to 1.2GA.  The hardest part was figuring out that I needed to add an assembly reference to System.Core for .NET 3.5 in my project.  Anyway, here's the one test I have working with LINQ and for comparison I'm also showing the original test without LINQ which does the same thing.

Friday, May 18, 2007 6:56:17 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |