OdeToCode IC Logo

The Partner Program Is Out Of Control

Friday, February 10, 2006 by scott

The Microsoft Partner program needs to simplify and streamline itself. Becoming a partner used to be a simple process with simple rules. Now there are  “bonus points” and other marketing tactics that make the program feel like a frequent flyer program. Partnerships are about marketing, but one day I won’t be surprised if someone calls to tell me I only need 2 more ‘partner points’ to get preferred ‘gold parking’ at the local Microsoft field office.

I just want software licenses.

I don’t have time to read the constant stream of emails, and I haven’t had the time the last two months to answer the numerous phone calls. Everyone who calls is pleasant and tries to be helpful, but no one can explain some of the deep voodoo in the system.

Take this one example…

I hold an MCSD certification. The SD stands for ‘solution developer’. To earn an MCSD I had to take certification exams covering programming tools and programming languages. The computers in the basement of the partner program science lab have analyzed my certification transcript and have decided I'm qualified for a single competency: the “Advanced Infrastructure Solutions” competency. This competency is for those who specialize in Active Directory and Exchange Server.

I installed Exchange once. I installed Biztalk once, too. Those were two of my proudest software installation moments ever.

I hope the program will offer less fluff, provide more licenses, and fix the wacky backend software.

Cargo Cults

Thursday, February 9, 2006 by scott

Perhaps you’ve heard the term ‘cargo cult programming’. Eric Lippert defined the term as follows.

There are lots of cargo cult programmers -- programmers who understand what the code does, but not how it does it. Therefore, they cannot make meaningful changes to the program. They tend to proceed by making random changes, testing, and changing again until they manage to come up with something that works.

The term derives from Richard Feynman’s “cargo cult science”. Feynman coined the term in a 1974 commencement address at Caltech. The speech transcript is a good read.

In the South Seas there is a cargo cult of people. During the war they saw airplanes with lots of good materials, and they want the same thing to happen now. So they've arranged to make things like runways, to put fires along the sides of the runways, to make a wooden hut for a man to sit in, with two wooden pieces on his head to headphones and bars of bamboo sticking out like antennas--he's the controller--and they wait for the airplanes to land.

The reason I bring this up is a Smithsonian Magazine article I read last week: “In John They Trust”. The author visited the remote island of Tanna to report on a real, enduring cargo cult. Villagers on Tanna worship John Frum, their American messiah. John lives in a volcano. John promised to return and bring shiploads of cargo, including bottled soda, canned meat, candy bars, and refrigerators.

Human behavior never ceases to amaze.

Namespaces and ASP.NET 2.0

Wednesday, February 8, 2006 by scott

I've seen grumbling lately over the lack of namespaces in ASP.NET 2.0 projects.

With Visual Studio 2003, if I add a page with the name of WebFormA to a folder with the name of FolderA, inside a project (named ProjectA), then the IDE starts off with a code-behind file that looks like the following.

namespace ProjectA.FolderA
{
   
/// <summary>
   /// Summary description for WebFormA.
   /// </summary>
   public class WebFormA : System.Web.UI.Page

The same steps with web project model in Visual Studio 2005 produces the following.

public partial class FolderA_WebFormA : System.Web.UI.Page
{

Some people believe having a class declared outside of a namespace is an unthinkable tragedy. My question is why?

One reason to use a namespace is to avoid type name collisions. By appending folder names to the front of the class, ASP.NET is avoiding name collisions (although I do wonder when someone will bump up against the max identifier length).

A second reason for using a namespace is to present a logical, organized hierarchy for consumers of the types. Who is the consumer of a WebForm? Typically only the ASP.NET runtime, which doesn’t need a namespace to help it map an HTTP request to an HttpHandler.

Types in a code-beside file are well hidden. The compilation model for ASP.NET 2.0 may even put each type in a separate assembly. In the scenarios where a Page, UserControl, or MasterPage code-beside type is needed outside of it’s own definition, the @ PreviousPage, @ MasterType, and @ Reference directives are needed. Pretending that these types are anonymous isn’t a bad idea. Using a base class or an interface will reduce the tight coupling that occurs when user control and master page types are used by other areas of an application.

If you still need to put Page derived types in a namespace, you'll want to consider using the Web Application Project type, which works like the 1.1 model.

Care and Feeding Of Community Server

Tuesday, February 7, 2006 by scott

Over the weekend, OdeToCode bumped up against it’s SQL Server disk space quota. Some operations, like adding comments, were throwing exceptions because the primary filegroup was full. Instead of paying for more disk space, I looked to see if there was some extra baggage I could get rid of.

Step 1 of the adventure was to verify the database size. The sp_helpdb stored procedure verified that the database was using almost all of the 100MB allocated by the ISP.

Step 2 was to see investigate the space reserved by each table in the database. The sp_spaceused stored procedure can list the amount of disk space used and reserved by a table, but only for one table at a time. The trick is to execute sp_spaceused with sp_MSforeachtable. sp_MSforeachtable is an undocumented tidbit inside SQL Server, but you can find information around the web (see Raymond Lewallen’s post, as a good example). The following script will display the space reserved and used for each table in the current database.

CREATE TABLE #TableSizes
(
  table_name
SYSNAME,
  row_count
int,
  reserved_size
varchar(10),
  data_size
varchar(10),
  index_size
varchar(10),
  unused_size
varchar(10)
)

INSERT #TableSizes
   
EXEC sp_MSforeachtable 'sp_spaceused ''?'''

SELECT * FROM #TableSizes ORDER BY table_name

The good news from the script was that content (blog posts, articles, and comments) only needed 10MB of storage. I still have plenty of headroom for incoherent ramblings.

Three tables stood out for using almost 70MB of the site’s 100MB quota: cs_Urls, cs_Referrals, and cs_SearchBarrel. I didn’t want to take away any of the search capabilities, as I actually use the search feature myself. The other two tables, however, track who has been coming to the site and from what location. I tend not to make use of this information, so the next step was to free up 60MB of space:

BEGIN TRANSACTION

DELETE FROM
cs_Referrals WHERE LastDate < '1/1/2006'

DELETE FROM cs_Urls
WHERE UrlID NOT IN
  (SELECT UrlID FROM cs_Referrals)

I chased the above with a COMMIT TRANSACTION once I was sure I had typed in the right table names.

At this point, the database was still as big as it ever was. I’ll admit I’m a bit hazy as to how and when SQL Server gives back reserved free space. I can only tell you what worked for me:

DBCC DBREINDEX (cs_Urls)
DBCC DBREINDEX (cs_Referrals)
DBCC SHRINKDATABASE(<database_name>)

DBCC DBREINDEX rebuilds all indexes. Since both cs_Urls and cs_Referrals have a clustered index, DBREINDEX effectively rebuilt the tables themselves, and the amount of reserved space for both dropped. DBCC SHRINKDATABASE then shrank the data file to under 55MB, and peace returned to the site. The irony is, I needed free space for these operations to free up space. As dbo I could bend the rules temporarily to make this happen.

Life With XAML

Saturday, February 4, 2006 by scott

It’s the Game of Life, and it’s written for WPF.

Read the article. Download the code.

Wierd Caching

Monday, January 30, 2006 by scott

Here is a (greatly simplified) piece of code that has been happily running on 13 production servers for one year.

private void DoWork()
{
    DataObject data = Cache[
"DataObject"] as DataObject;
    
if (data == null)
    {
        InitializeCache();
        data = Cache[
"DataObject"] as DataObject;
    }
            
    data.ToString();
}

private void InitializeCache()
{
    Cache[
"DataObject"] = new DataObject();
}

The above code has a flaw. We can’t depend on a cached object still being in the cache when we are ready to use it. The code assumes it can place an object in the cache and (almost) immediately pull it back out. Even with the flaw, the code never caused a problem in production environments that log all exceptions. 

The weird part is that the data.ToString() line occasionally throws a NullReferenceException on one (and only one) developer machine. How odd that the code fails on a developer machine serving a single request at a time. It’s good the weirdness occurred, because it pointed out a problem. The fix is to return a reference from the initialize cache method, and not to depend on the ASP.NET cache to keep the object alive.

I Don’t Even Trust My Real Mail Now

Sunday, January 29, 2006 by scott

I opened a posted letter from a bank today. The letter said I needed to return a form with my name, date of birth, and social security number, or my account might close in 90 days.

I thought it was odd that a bank I’ve been doing business with for 5 years didn’t know already know this information. With the ridiculous amount of fraud I see in my email everyday, I was suspicious. I called the bank using a phone number I found on the bank’s secure website.

I remained suspicious until I was on hold for 20 minutes. At that time I knew I had the right bank. Indeed, they did want to verify my information against the information they have on record.

It’s sad, perhaps scary, that I trust an SSL endpoint more than the mailbox at the end of the driveway.