Email:
Copyright 2005 Randy Charles Morin
Part of the KBCafe Blog Network.
Cool Programming
Cool Programming Tips with C#
Fri, 09 May 2008 04:48:39 GMT
Web 3.0?

This might be Web 3.0. You have to view the samples in Firefox. This could contribute to the death of Flash. It's basically a graphics library written for Javascript.

http://ejohn.org/blog/processingjs/

Mon, 28 Apr 2008 16:57:54 GMT
Fire Your Best Programmer

More and more, I'm coming to the conclusion that who managers think is their best programmer, is often their worse. So, managers could fire their best programmers and improve their organizations. Here's why. If you ask a junior programmer to develop a component to retrieve NS records, then he'll like write a class called DNS.NameServers and implement a public method like Get(domain) return IP[]. Ask a senior programmer and he'll write a DNS library with classes like Request, Response, Resolver, etc. They likely will take approximately the same time, the junior writting 200 lines of code and the senior writing 20,000 very well documented lines. Which do you think is easier to maintain? Which do you think is easier to use?

Tue, 05 Feb 2008 15:55:20 GMT
Refactoring
In the last couple days, I merged 5 webpages that were very similar, reducing the total line count down from 5000 to 1500. It was a lot of scary work, but now that it's complete, I can make bigger changes without having to write the code 5 times. A step further, those same pages could be merged with another 10-20. Where does it stop? I could end up refactoring the rest of my life and never writing a new feature.
Thu, 06 Dec 2007 15:28:29 GMT
C# Convert.ToDateTime Bug
Today, I noticed that .NET 2.0 cannot parse the following formatted date; Sat, 01 Dec 2007 00:00:00 PST. The problem appears to the the PST timezone, which is clearly valid. Many of the date parsing problems related to RFC 822 in .NET 1.0 and 1.1 were fixed, but I'm amazed that some issues still exist.
Sat, 24 Nov 2007 14:57:35 GMT
How Many Nines?

Quite often, when we talk about server up-time, we talk about how many nines. The nines indicate uptime. One nine uptime means 90% up-time. Two nines means 99%. Three nines 99.9%. And so one.

The truth is that almost every application is exactly 1 nine. In order to be less than 1 nine, you have to be down for 72 hours in one month. I suspect that happens to many applications, but not month-after-month.  In order to be 2 nines, you have to be down for less than 7 hours per month (3 nines is less than 1). If I look at websites I use, almost all of them are down for at least 7 hours per month, but rarely 72. I don't have any stats, but I suspect that 80% of the websites have 1 nine up-time.

Conclusion: We need a new scale. 98% up-time is very good for a website. 91% is very bad. Yet, both are the same nines.

Fri, 19 Oct 2007 19:05:03 GMT
Developer Manages Bugs?
The project manager on my current project just said that usually the lead developer is responsible for managing the bug/issue list. Wow! I can't believe he just said that, particularly since he claimed responsibility for this task only two weeks earlier. Just what is the project manager suppose to do if the lead developer manages the project?
Wed, 03 Oct 2007 16:25:30 GMT
I hate Graphic Designers

The last couple websites that I worked on where we hired a graphic designer, we ended up blowing our deadlines because the graphic designers couldn't do their jobs. I have three problems in particular with their performance on these projects.

  1. Instead of just laying out the site, they would come up with new ideas (features) and try to inject them into the site design. Worse, they don't present them as new features to the team, rather they simply add them to the webpage layouts and hope the developers just code them. The developers often don't know any better and all of a sudden you have a feature that wasn't in the requirements. Development takes longer than it should and you blow your deadline.
  2. Quite often, graphic designers use the opportunity to review the work done by development to make their own original designs better. This creates an endless iterative approach. Once a webpage layout is approved, it should not change, unless their is a valid reason and valid reason isn't that the designer thinks it would be better another way.
  3. While the designer tried to sneak a bunch of new features into the website, they often fail to do their own work. In order to make their own deadlines, they change pages to reduce their workload. Dropping webpages, copy and content. In the first run-thru, we had several placeholders where the design team was suppose to fill in copy later, as they didn't have time to produce the copy in the first run-thru. Later, they resolve most all of the copy placeholders by saying "just drop the placeholder, the webpage is sufficient as-is."
Thu, 06 Sep 2007 13:00:02 GMT
The Basics of DEV

Software development really isn't as hard as it seems. There's some basic things that can make it really easy. When you don't do these things, then softtware development can get very complex, very quickly.

  1. Source Control - Unbelievably, most development shops don't use a source repository like Source Safe or CVS. Only one of the last four companies I've worked for have had source control in place when I got there. Two had no source control whatsoever and one of those was a Social Website startup that later sold for $millions. Once had source control within the company, but it wasn't centrally managed.
  2. Change Control - Better known as bug tracking software, this is the process of creating, assigning and resolving bugs in your software. Three of my last four companies didn't have any at all and the other had the software bug didn't use it (at least I didn't). Most of those companies used Microsoft Excel to track issues.
  3. Scheduling - Project scheduling software like Microsoft Project is also a necessity and I've not seen a project schedule that wasn't prepared by myself in years. I've received emails with major milestones deadlines, but that's like using Excel to track bugs.
  4. Builds - A proper build can eliminate a lot of configuration issues. You may have heard a developer respond that the non-functioning website works on his desktop. That's like a configuration problem caused by not having a proper build process. Only one of the last four companies I worked for had a build prior to me joining.

This is four basic tools for removing the complex in software development. How many are you using?

Sun, 01 Jul 2007 16:34:00 GMT
How To Set a Global HTTP Proxy

I ported some code to an environment that required an HTTP proxy to get outside the firewall. The code is very simple and worked immediately.

System.Uri proxyURI = new System.Uri("http://64.202.165.130:3128");
System.Net.GlobalProxySelection.Select = new System.Net.WebProxy(proxyURI);

Tue, 19 Jun 2007 19:31:15 GMT
The Faster and the Slower

The faster Intel makes the computers, the slower Microsoft makes them. I remember years ago unzipping 1000 small files in less than one minute. Now, unzipping those same files on a faster computer takes several minutes. Why? Simple. As Intel makes the computer faster, Microsoft writes more robust code to make it look cool, but perform ever more slowly. The graphics in Vista are grinding my computer to a halt.

Fri, 25 May 2007 07:01:16 GMT
Windiff for Vista
I searched for hours today for a version of Windiff that'll worked on Vista. There were many options, but nothing from Microsoft that would install successfully until I found the Windows 2003 SP1 Support Tools.
Tue, 22 May 2007 23:28:45 GMT
Single Sign-On
I've been working on a new computer network lately and they have this concept of single sign-on. I don't think they quite understand what single sign-on means. IMHO, it means you sign-on once and get authenticated across many systems, so you don't have to sign-on a second time. The operators of this network seems to think that single sign-on means you have one sign-on ID across the various systems. In fact, it's not even possible to synchronize your passwords across the various systems, becaue the password have conflicting requirements. So, you have different credentials in every single system across the network. This is really difficult, because I have to sign-in twice, just to get to what I want.
Thu, 10 May 2007 21:56:37 GMT
Facebook API

I just finished applying the Facebook API to import a resume into ResumeBay. I have to say that Facebook has the most complex API that I've even developed against. It's so complex, that it clearly out of the capability of the average developer. To start, you have to redirect the user to the Facebook website in order to login. Once the user returns to your site, the real complexity begins. Even after the user has logged-in and you receive an authtoken, you still have to get a session id. Stop. getSession is a REST call and all the REST calls require a signature parameter. The signature parameter is an MD5 of a string. The string is the catenation of all parameters in name=value format with a secret string appended. Each API also has a call counter that must increase with each new method call. Now I have the session id. Call another API to get the user id and finally a last API call to get the user profile. Don't forget that you have to enumerate every field you want in the profile in another comma delimited parameter. A total of 100+ lines of code just to get the user's profiles. Imagine if I wanted to do something complicated.

http://www.resumebay.net/blog/?guid=20070510163857

Tue, 01 May 2007 02:50:16 GMT
Email ASP.NET Exception

Of late, I've started expanding the amount of websites that I'm starting. As such, I've realized that their is tremendous value in a default set of code where I can start programming. For instance, today I decided to add to that, the ability to email the webmaster all unhandled exceptions. Anyhow, here's the best solution I found.

http://www.systemwebmail.com/faq/3.4.aspx

Sun, 29 Apr 2007 04:04:30 GMT
Don't Change the XML Namespaces
I'm very frustrated with XML grammars that change so radically that you need special processing to convert one to another. This is something I've really liked about RSS. Most all legacy versions of RSS remains valid today. On the other hand, there's HR-XML. They change the namespace with every new release, thus making every version incompatible with every other version. I guess its a cool way of denoting version. I also love the version attribute in RSS.
Sun, 29 Apr 2007 01:34:20 GMT
Open Complexity
Today, I came across a sourceforge project that did something similar to what I was trying to accomplish. I dug into the source code only to find it was too cryptic to be re-used. For example, a variable that would have the English meaning Puzzle Piece, was pp. That's not a real example from the project, but one that demonstrates what the coder had done. After awhile of trying to read this cryptic code, I began to suspect that this was intentional on the author's part. His project was open-source and clearly his algorithms had value. What better way to make sure someone doesn't re-use your code, then to make it complete cryptic. So  why sourceforge?
Thu, 26 Apr 2007 02:49:44 GMT
TextSnippets

TextSnippets has a great collection of useful code.

http://textsnippets.com/

Wed, 28 Mar 2007 17:47:16 GMT
IE7 and Firefox

At least once a month, someone sends me a link to their new consumer Web 2.0 compliant website. I click the link to their website and it launches IE 7.0 and the site looks like someone threw-up on my browser window. I then load the same webpage in Firefox and it's beautiful. 

I have access to stats from various websites and the percentage of users that use Firefox is usually between 20 and 30%. The percentage using IE 7.0 is between 15 and 20%. The percentage using IE 6.0 is between 40 and 50%. All other Web browsers are below 4% with IE 5.0 and Safari having as much as 3.x% share at best.

I assume that 55 to 70% of this Web 2.0 company's visitors are lost. Now, I'm not saying that every single webpage needs to work on every browser and I'm certain some of my webpages don't work in some browsers, but when your homepage doesn't work for the majority of your visitors, then you really have major problems. I know most developers use Firefox exclusively, but you really have to test your stuff in IE7 or failure is inevitable.

Thu, 22 Mar 2007 15:15:57 GMT
Tip #1113
Tip #1113 in developing good software. Don't use components whose version number begins with a zero. I'm sure the component owners of 0. software will disagree and I'm also sure they will tell you it was beta and shouldn't be used in production software when it stops working.
Mon, 26 Feb 2007 16:52:13 GMT
Understanding Over-design

One of the biggest problem in software development is over-design. Most programmers will often over-design their software and cause bugs in the process. The best example of this is the phone number control. Ask a programmer to develop a control that accepts phone numbers and you'll often get a control that has keystroke validation that forces the phone number to the standard (xxx)-xxx-xxxx format. This is what my cellphone expects. Why is this incorrect? I can't enter extensions. I can't enter overseas phone numbers. I can't enter alpha equivalents. A simple input box that limits the length of the string to 64 characters is clearly a better solution, but most programmers will over-design on this simple task. In fact, it's a given that somebody will suggest that I'm wrong in the comments.

Sat, 24 Feb 2007 20:01:42 GMT
ThreadStateException in NUnit

I use NUnit a lot. In fact, I doubt many have written more NUnit tests than I. I think I've written about ten thousand tests. I love the entire idea of regressive unit testing. That's one reason I believe my software is less buggy than most. Unfortunately, NUnit is extremely buggy. Fortunate that it is used by very technical people, because if you wrote software this buggy for mundane users, then you'd likely have no users at all. With each version of NUnit, thousands of bugs are fixed and thousands more are introduced. I just upgraded my NUnit to the latest 2.2.9 and of course, hundreds of tests are broken. Here's a simple code fragment they broke.

using System;

namespace TestHarness
{

[NUnit.Framework.TestFixture()]
public class UITests
{

[NUnit.Framework.Test]
public void SurfHomepage()
{
  System.Windows.Forms.WebBrowser browser 
    = new System.Windows.Forms.WebBrowser();
  browser.Navigate("http://www.r-mail.org");
  while (browser.ReadyState != 
    System.Windows.Forms.WebBrowserReadyState.Complete)
  {
    System.Windows.Forms.Application.DoEvents();
  }
}

}

}

What the NUnit team did was hardcode NUnit to use the MTA apartment thread, which no longer works with the .NET 2.0 WebBrowser object that requires STA. If you run this test, then you get the following error.

TestHarness.UITests.SurfHomepage : System.Threading.ThreadStateException : ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

Another problem with NUnit is that its horribly documenting. Searching for a solution to this problem was extremely difficult. A dozen of red herrings before I found two threads that vaguely identified the solution. Which I'll document better here.

The solution is to create a .config file for your tests. Follow these steps.

  1. Locate NUnitTests.config in Program Files\NUnit\bin.
  2. Copy this file to the same folder as your .nunit file.
  3. Rename this file to match your .nunit file. If your .nunit file is test.nunit, then rename this .config to test.config.
  4. Now open up the new .config file and locate the ApartmentState parameters.
  5. Change this parameter from MTA to STA.

If you are using the NUnit console instead of the NUnit GUI, then local the .config file in the same folder as your test DLL and rename it accordingly.

Fri, 23 Feb 2007 01:20:09 GMT
Register Express Again Please!
I use Visual C# Express, Visual Web Express and SQL Server Express quite a bit. Lately, I've notice that I've had to again re-register all my express software. In some cases, I've had the software installed for more than a year and I must have previously registered the software. There appears to be a registration problem with the Express line of software that causes you to have to re-register at times.
Mon, 19 Feb 2007 06:00:59 GMT
Geocode.ca

Geocode.ca is an awesome web service. Given various criteria, it'll return longitudes and latitudes in XML. Here's a C# programming sample.

http://geocoder.ca/

Mon, 19 Feb 2007 02:50:08 GMT
System.UnauthorizedAccessException in IIS

The most frustrating error in ASP.NET is when you locate your Web folder outside of the wwwroot folder. If you copy file to that location, then giving the ASPNET or IUSR_XXX user access doesn't always help.  You also have to give permission to IIS_WPG. I pier developer had this problem 3 years ago and simply couldn't find this solution even after days of research. Hopefully, this will save someone somewhere some time.

Read more here.