Archives / 2008 / December
  • Slow Script Loading by FireFox with Cassini

    Bertrand just posted about a bug I’d encountered before but never tracked down wherein FireFox (and in particular, FireBug) is extremely slow in loading scripts for a local web site running on Cassini (Dev Web Server).  It turns out that the issue has to do with an FF bug trying resolve “localhost” using IPv6.  Dan Wahlin follows up with the fix, describing how to disable IPv6 in FireFox.  Since the issue has to do with name resolution, another workaround is to simply change the URL from using localhost to using With the bug in place, individual requests typically take over a second.  Using or disabling IPv6 in FireFox results in the expected 5-25ms … more

  • IFileSystem Dependency Inversion Part 5

    The saga began here. Where I left off, I'd managed to create a new class for handling the storage of my creative files, called CreativeFileStore.  This method took in an IFileSystem as a parameter to its constructor, which provides two benefits: Testability Flexibility - I can swap between WindowsFileSystem and AmazonS3FileSystem easily In the interest of keeping the individual posts at a reasonable size, I didn't include all the tests for the CreativeFileStore, but here's a summary: 1: [TestMethod] 2: public void Create_CreativeFileStore(){} 3:  4: [TestMethod] 5: [ExpectedException(typeof (IOException))] 6: public void WriteFile_Fails_If_File_Already_Exists(){} … more

  • IFileSystem Dependency Inversion Part 4

    Still working on cleaning up some legacy ASP.NET code.  Here's where we are: Part 1: Define problem and demonstrate IFileSystem basic version Part 2: Spike solution to support saving files in IFileSystem that works in both Amazon S3 and the Windows file system Part 3: Initial refactoring via TDD of big ugly method Now it's time to take the big step of pulling the main ugly method guts out into its own object.  Since the main purpose of the method, GetImageOrFlashData(), is to store a file that has been uploaded, I'm thinking at the moment that the name for the class who will take on this responsibility is going to be CreativeFileStore (a creative is a noun in this context; a … more

  • IFileSystem Dependency Inversion Part 3

    In part one I described the problem.  In part two I worked out the details of how to save files in a platform-ignorant way by creating a spike solution.  Now I'm looking back at my original ugly method from part one and extracting it into its own class that accepts an IFileSystem instance via constructor injection. Looking at the original method, it has a number of dependencies and issues.  My next step is going to be to get it out of the untestable ASP.NET codebehind file and into a separate class.  Doing so is going to require me to replace all global references with method parameters or properties on whatever class I create.  Here's my first pass at things I need … more

  • IFileSystem Dependency Inversion Part 2

    In my last post in this IFileSystem series, I described the problem I'm working on of removing a dependency on the System.IO Windows file system in my ASP.NET application.  A bit of research on this subject revealed some help on making file uploads testable by ScottHa, but his technique still makes use of the SaveAs() method and ultimately ties the solution to the server file system.  A similar post on creating Unit Test Friendly File Uploads was more helpful, in that it provided some helper methods for saving files from HttpPostFile without using its built-in SaveAs() method. Since my ultimate goal is to be able to swap between Amazon S3 and Windows file systems (and likely Azure … more

  • Installing Graffiti Extras

    I’ve been wanting to add Next/Previous links to my blog’s posts to provide easier navigation for folks who come to the blog and find themselves somewhere in the middle of it.  My goal is for the top and/or bottom of each post to have something like this: << Blog Post Title | Blog Post Title >> Most likely my designer will make it look better than this, of course.  A quick search revealed that Graffiti Extras includes this functionality.  I thought I’d grab the Binary release and fired up my FTP client and was ready to do things the old-fashioned way when I discovered the Package option is actually a much easier way to go.  What’s a package?  Well, … more

  • IFileSystem Dependency Inversion Part 1

    In the course of making my software more testable, I’ve attempted to eliminate a dependency on the file system (in this case, via System.IO) by creating an interface, IFileSystem.  I just did a quick search for this term and came back with only one C# interface (in the first few results) that matches this, which is for CC.NET, and looks like this: My basic version of the interface is similar: public interface IFileSystem { bool FileExists(string path); void MoveFile(string oldPath, string newPath); string ReadAllText(string path); } From this, I was able to extract some simple System.IO dependencies that were detecting if a file existed and moving it.  … more

  • Energy Usage

    Rick has an interesting post about his experiences measuring electricity use of various components in his home.  I’ve been curious about this myself for some time, but haven’t had the tools or time to track it.  I think I’ll pick up one of these usage monitors (like Rick did) and of course (eventually) report my findings.  I’m thinking I’ll pick it up for the office, so it’ll be a business expense…  Plus we have a ton of things using power at the office, including a fridge and a microwave, a projector, and of course computers, printers, etc.  Be cool if this gadget logged usage to a memory stick and you could download it into Excel or something rather…  not … more

  • SEO Tip Move Hidden ASPNET Fields To Bottom of Page

    Here’s a quick SEO tip from Teemu (via email) that I’ve been meaning to mention – there’s a new feature in .NET 3.5 SP1 that lets you control where hidden form fields are rendered by ASP.NET.  To set it, go into web.config and add the following: <pages renderAllHiddenFieldsAtTopOfForm="false" /> The default for this is true (which is how it’s always behaved since 1.0).  You can read more about it on MSDN. What’s the point? There are pros and cons to which way you go with this setting.  The default setting ensures that the data in hidden form fields like __VIEWSTATE is available early in the browser-side page loading cycle, so that if a user … more

  • Func Mousepads

    I bought an Alienware laptop a few years ago as sort of a gift to myself after coming back home from Iraq.  As it turned out, that computer didn’t actually last very long because of Alienware’s crappy support policy, but it did come with a Func Industries mousepad that I still use to this day.  Let me tell you why. Back in the day, I used to have time to play computer games, and I was a bit of a Counterstrike addict.  I wasn’t the best or anything, but I had a lot of fun with the game.  One thing that’s required for such First Person Shooter games is a decent mouse, and ideally a decent mousing surface.  This is why Alienware, the self-proclaimed gamer’s computer … more

  • Head First Design Patterns

    I picked up Head First Design Patterns a couple of months ago and read it last month.  I have to say that this book is totally different from any other software development book I’ve read in the past.  Most software books, you probably know, follow a fairly predictable pattern with each chapter covering some piece of technology through large amounts of text interspersed with code blocks and screenshots.  Some are a bit different, like cookbooks that have recipes for various tasks or Murach’s titles that lay out explanations and code on opposite pages.  But in general, they’re pretty dry and tend to follow a very predictable, dare I say boring, structure.  If you’re … more

  • Personal Goals 2008 Update

    My progress bar for 2008’s goals completed is resembling a Windows Vista file transfer dialog in terms of its responsiveness and accuracy.  That is, it went to 20% back in January, and there it sat for 11 months until earlier this week when it moved up to 40%.  Now it’s pretty much (Not responding) which doesn’t bode well for my goal accomplishment ratio… As a recap, I started off the year with 5 personal goals for myself.  I figured if I blogged them perhaps it would increase the chance that I would get them done.  And perhaps it did – it’s at least kept them on my mind and given me a place to refer back to from time to time to see how I’ve been doing.  But on the … more

  • ASP.NET MVC at DogFood Developers Conference

    I gave a presentation a couple of weeks ago at the Columbus Ohio Microsoft Dogfood Developers conference.  Danilo, the main organizer of the event, snapped a couple pictures of me during the talk.  This was my first time presenting on ASP.NET MVC and I want to definitely thank ScottGu, ScottHa, Phil Haack, and Jason Gaylord for their great presentations on this subject, from which I borrowed and added my personal spin and perspective.  Jason was kind enough to let me use his simple blog application as the basis for my demos, which I extended by making it fundamentally more testable.  I apologize for taking so long to get the slides and demos posted – it’s been a crazy … more

  • CodeMash 2009

    The 2009 Conference Season kicks off early in Ohio with CodeMash 3.0.  This is the third year of the event and promises to be a valuable experience with a diverse mixture of software development technologies.  This year I’m happy to report that I will be speaking about techniques to improve web application performance, a topic I’ve spoken on frequently to ASP.NET audiences and one which I’ll be expanding to include techniques applicable to a variety of web platforms. In the course of registering for the event, I was please to note that they actually got their Company Size field right!  I’ve blogged in the past about off-by-one errors in various surveys that discriminate … more