Saturday, December 10, 2005

Private Strong-named Assemblies Not Supported

I was surprised to learn (the hard way) this week that Microsoft doesn’t support strong-named assemblies if they are deployed to the \bin directory of an ASP.NET application. If you need proof, check out these links:

 

http://support.microsoft.com/?id=813833

http://support.microsoft.com/?id=324519

 

There are two reasons to sign you assemblies:

  1. Install in the Global Assembly Cache (GAC)
  2. Install a Serviced Component into a serviced or library Component Services application

 

Once you have signed an assemblies, that assembly can only reference other signed assemblies.

Previously to finding that deploying signed assemblies privately is not supported, I would sign my assemblies whenever I started a new project. This way if I decided down the line that I wanted to install in the GAC, I didn’t have to re-build with a sn.exe key.

Has anyone heard about this?

 

Friday, November 25, 2005

Unit Test Database Code with COM+ (Enterprise Services)

I’ve been using NUnit for a couple years now and love it. However, most of my applications use databases extensively and most of the features within these applications have to do with managing the data in the database. This means I don’t have a lot of business logic for these operations, but I do have a lot of code that interacts with the database. I need unit test for that code. This is where COM+ comes in.

If you have talked to me about unit testing, I have probably mentioned using COM+ with unit tests to rollback any database transactions that occur within the context of the unit test. This means you can insert, update, delete and select data from within your unit test and when the test in completed, all changes will be rolled back. Since I’ve started using it, I can’t live without it. I don’t have any database dependencies with my tests, they are all self supporting. Plus, if you run the tests against a production database (on accident or to troubleshoot) the production data will not be modified.

Roy Osherove gives the details here.

One other tip I just learned that is associated with this method. You can read the “dirty” records within the database if you are stepping thru your COM+ unit tests by changing the transaction isolation level in Query Analyzer.

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

 

Saturday, November 19, 2005

Agile Management

 I’m sure you have seen the Agile Dilbert cartoon. I’ve been sent this cartoon from a couple people at work and now Javier is looking for my comments…So here goes.

The comic highlights that management doesn’t seem to understand the business impact of agile methods. There is a strong, embedded culture in management for fixed feature, fixed budget, and fixed timeline projects. In most organizations, this culture comes from the budget process. The budget process is similar to the waterfall method for software development. You define your objectives for the following year (scope), determine the hard costs to achieve those objectives (costs), track the budget through out the year(deadline) and tie a bonus for staying within budget.

What happens at the end of the year? If there is money left in the budget, managers find a way to allocate the money so they won’t lose the budget next year. Not very efficient! If they are short on money either move money from another budget, or find some ways to cut some costs last minute.

I think management would improve by implementing a more agile process. What if they supplement the long term objectives with short term goals (iterations), track progress along with costs (burn down) and have the option to change or cancel the objective if the business value isn’t found.

We are a long ways away from this happening, but there is hope. In Jack Welch’s new book, Winning, he talks about changing the fixed budget culture within G.E. to an “Operations Plan” culture. The operations plan is a yearly plan that outlines goals and costs for the company with flexibility to change over time. This frees managers to make decisions that are good for the business, not just good for their bonus.

Thursday, November 10, 2005

VS.NET SQL Projects

On my current project, we’ve been using the SQL Project that’s included with VS.NET. I did this with some hesitation. I wanted the scripts to be integrated with the IDE, but I’ve never had any luck with managing SQL scripts. I had 3 issues:

  1. The command file that VS.NET generates never executed my scripts in the correct order. If you execute a stored procedure that has a column that doesn’t exist, you’ll get an error
  2. How do you manage scripts that should only be run once? You don’t want to add the same field twice.

  3. Keeping code synchronized with the database changes

After some research and trial and error we fixed the first issue. I didn’t realize (since it isn’t documented anywhere that I could find) that the command file uses the script’s file extension to determine the order of scripts in the .cmd file. So it is important to name your files with the correct file extension.

The “Rules”:

  1. Table files with the .tab file extension
  2. Stored procedures with .prc
  3. Finally .sql files for all data modifications

The second problem, we fixed with a simple rule: “All scripts must be able to be run multiple times”. What this rule means is that if a script is going to add a column to the table, the script needs to check if the columns already exist before running. This rule also makes it possible to integrate our SQL changes into our nightly build process. This is great because we validate our scripts every night; schema changes, data, and security settings.

Third, we simply created a folder for each version of the software. Under each version folder we added a folder for each database. The database folders allow us to right click and “Create Command File…”.

How do you handle your database changes? I’m always interested in suggestions.

Saturday, September 17, 2005

Architecture and XP - Kent Beck's perspective

Two questions continually haunt with with Agile practices:

1.) How do you handle fixed bid/fixed scope projects without affecting quality?
2.) Where and when is the architecture defined?

In this article Kent Beck provides his perspective. Well worth the read.

"My experience with architecture shapes the architecture strategy in XP, I repeatedly ran into architectures that were developed up-front, without feedback, and by groups which didn't have to live with the day-by-day consequences of their decisions. What I observed about successful architectures was that they were grown little-by-little." - Kent Beck

http://www.theregister.co.uk/2005/09/11/beck_on_xp_architecture/

Thursday, September 15, 2005

First Iowa Agile Meeting, 9/22 @ 6PM


We'll have our first Iowa Agile meeting on Thursday, September 22, 2005 at 6:00 PM at Rock Bottom Brewery in West Des Moines.

Thanks to Kent McDonald for setting this up.

Tuesday, July 12, 2005

Business Rules vs. Validation

I spent lunch with Patrick Korte, Steven Phillips, Toby Schau, and Nick Parker discussing business rules, validation, controllers and my general dislike for web projects over some great cafeteria pizza (I'm jealous).

This discussion started after our last Iowa .NET user group meeting and a deep discussion about validation and Rocky's CSLA.NET business object framework and how each of use were handling this problem.

My main issue is how to manage validation based on the context of the object. My behavior is different in a bar on a Friday night from my behavior at work. My context determines if my behavior is “valid”. Should each of these contexts have it's own derived class? I'm afraid of a potential class explosion.

Another issue is how to manage cross object validation. This is when one object needs data from another object to determine if the object is valid.

We discussed the possiblity of managing the context/cross object validation problem via controllers/collaborators that act on the domain objects. Some expressed concerns about the class explosion happening to the controllers.

Guys, what else did forget?

I'm looking forward to our next discussion

Saturday, April 30, 2005

My local project is not fully trusted by the .NET runtime....ZoneStripper to the rescue

I started working on a DotNetNuke site for a local charity this week. I downloaded the latest build and extracted it to my local hard drive, but when I opened it, I got this error:

The project location is not fully trusted by the .NET runtime. This is usually because it is either a network share or mapped to a network share not on the local machine. If the output path is under the project location, your code will not execute as fully trusted and you may receive unexpected security exceptions.

What? My local hard drive shouldn't be trusted. That's probably true, but how does Microsoft know? If you're running Windows XP SP2 on an NTFS partition it tracks the Zone for all files. Since my DNN files were created on another machine, they're flagged as coming from the Internet Zone (ZoneId=3).

You can view the setting in notepad. Enter this at the command prompt: notepad.exe DotNetNuke.sln:Zone.Identifier. It will display a file stream similar to this:

[ZoneTransfer]
ZoneId=3

How do you remove/change this setting? Windows provides an interface to remove this setting in the file properties dialog, but you have to click “Unblock“ for each file. (uhg!).

Luckily there is a free utility named ZoneStripper that will recursively clean all the files in your directory. Check out the readme after downloading the code. It explains what is happening in more detail...if you are interested.

Sunday, April 17, 2005

Web Projects Boycott, Long Live Class Libraries

I try to be a good programmer. I understand that there will be other programmers who will come after me and have to maintain and update my code. I think of these poor souls (you know who you are) when I'm setting up a solution and designing a new system.

One of the simplest things I do is organize my code so that resides in an intuitive folder structure. First I create a Solutions directory, then I add each project under the solution's folder. That is until I try to add a Web Project. By default, the web project is added to the home directory of the Default Web Site in IIS, generally C:\inetpub\wwwroot\. I try to “trick“ VS.NET by creating a virtual directory and pointing it at my project directory, then hack my .webinfo file to get everything to work correctly, but this seems to cause Source Safe to complain when another developer tries to get latest.

\Solution.One
      \src
           \Solution.Project1
           \Solution.Project2
           \Solution.Project3
           \Solution.WebUI

The other issue I have with web projects it compiles all the files into one assembly for the entire website. The websites that I develop have multiple teams working on different sections of a website, with each team having it's own release schedule. How does the “admin“ section team release its changes to production, but not release the updated code for the “news“ section team? If they are both working under the same web project the simple answer is, “they don't“. When the project compiles all the code is compiled into one assembly.

Solution (er...Hack)
But then I started to think, how is a web project different than a class library project? Besides specific file types for web development (.aspx, ascx, asmx) and a virutal directory,  they are the same. Even the project type of a web project property says “class library“. Hmmm....

What would happen if I created a class library project, pointed a virtual directory at it, added a web.config file and a .aspx page? Well, it works just like a normal web project. This solved my problem. Each section (folder) of the web project would be in its own class library. I would point the output directory for all the projects to the same \bin directory at the “root“ of my web application. Everything will work this way. The next problem I ran into was that the class library projects don't have the ASP.NET file types in the “Add New Item...“ dialog box, but I found this article that explains how to fix that problem.

The good news is that all of my issues with the web project goes away with VS 2005. Each web page compiles into it's own assembly. However with VS2005, I have some other issues that hopefully I will blog about later...

Monday, March 21, 2005

Farewell Two Rivers Marketing...Hello Gran Turismo

Friday was my last day at Two Rivers Marketing and to celebrate we headed over to Champps at Jordan Creek to grab some grub and cheer on the Iowa State Cyclones basketball team.

I was honored to work with everyone at Two Rivers Marketing. They are a great crew that is willing to learn and put in the extra effort to exceed client expectations…They are a great fit with my style of development.

During our outing at Champps, the team honored me with an AWESOME gift… a PlayStation2 and Gran Turismo 4. They all chipped in to get it for me. I guess they got sick of me whining about not having one. It was completely unexpected and I couldn't have been happier. Every time I play, I'll think about riding to lunch with Keith driving….Best of luck guys.

Saturday, January 15, 2005

Introducing Agile Methods

Peter Schuh has written a practical article about introducting Agile methods. I don't believe in sweeping changes it implement Agile methods, and my approach is similar to what Peter recommends.
"...do not bill yourself as Team Agile. Do not make a big deal about trying Agile. In fact, try to bring as little additional attention to the team as possible. The team will need time to work through even a single practice, to measure its benefit, to tweak its implementation, and to ultimately embrace or reject it. You do not want to tie your team’s hands or put them under the microscope.

Let the results of your foray into Agile speak for themselves. If the team’s performance is improved, your customer, your boss, and your customer’s boss are all likely to notice."

Traditional--with a Twist by Peter Schuh