Scott Hanselman

Some Guiding Principles for Software Development

June 13, '07 Comments [22] Posted in Learning .NET | Musings | Programming
Sponsored By

Patrick Cauldwell is one of the architects on our Next Generation Banking System. A while back I asked him to write up our guiding principles for not only educating new developers but also for indoctrinating existing team members into our world view. He published it on his blog as This I Believe...The Developer Edition.

It's a great list. Here's a partial listing of the first two levels of his outline. Be sure to visit his post for the complete outline. It's bent towards .NET, because the stuff he's doing is .NET, but the general ideas are usable elsewhere.

  • Our "guiding principles"
    • Test Driven Development
    • Continuous Integration
  • Unit Tests
    • Two kinds of tests
    • Automation is equally possible for both sets of tests
    • All UI development should follow the MVP pattern for ease of testing
  • Test Coverage
    • 90%+ is the goal
    • NCover runs as part of the build, and reports are generated
  • Buy, Not Build
    • Take full advantage of the platform, even if it only solves the 80% case
    • Don't write a single line of code you don't have to
    • Take full advantage of .NET 3.0, SQL 2005, Windows 2003 Server, plan for- and test on Longhorn.
    • Don't invent new solutions to solved problems.
  • Limit compile time dependencies on code you don't own
    • Everything not owned by us should be behind an interface and a factory method
  • Define your data contracts in C# (think "active record")
    • All persistent storage should be abstracted using logical interfaces
  • Fewer assemblies is better
    • There should be a VERY good reason for creating a new assembly
    • The assembly is the smallest deployable unit, so it's only worth creating a new assembly if it means NOT shipping something else
    • Namespace != assembly name.  Roll up many namespaces into one physical assembly if they all must be deployed together.
  • Only the public interface should be public
    • Only make classes and interfaces public if absolutely necessary
    • Test code should take advantage of InternalsVisibleTo attributes
    • VS 2005 defaults to creating internal, not public classes for a reason
    • If it's public, you have to support it for ever
  • Windows authentication (good)
    • Just say no to connection strings
    • Windows authentication should be used to talk to SQL, ADAM, the file system, etc.
    • You can take advantage of impersonation without impersonating end users
  • Tracing
    • Think long and hard about trace levels
    • Use formatted resource strings everywhere for localization
    • For critical, error, or warning, your audience is not a developer
  • Error Handling
    • Method names are verbs
    • If anything breaks the contract, throw an exception
  • The definition of "done" (or, how do I know when a task is ready for QA?)
    • Any significant design decisions have been discussed and approved by the team
    • For each MyClass, there is a corresponding MyClassFixture in the corresponding test assembly
    • MyClassFixture exercises all of the functionality of MyClass (and nothing else)
    • Code coverage of MyClass is >=90%, excluding only lines you are confident are unreasonable to test
    • No compiler warnings are generated by the new code
    • Before committing anything to source control, update to get all recent changes, and make sure all unit and integration tests pass
    • FxCop should generate no new warnings for your new code
    • Compiling with warnings as errors will flush out any place you forgot documentation comments, which must be included for any new code

What guiding principles do you follow at your development shop?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

The Value of Writing Windows PowerShell Cmdlets

June 13, '07 Comments [2] Posted in Corillian | PowerShell | Programming
Sponsored By

image The folks at Channel 9 dug up another interview I did with Jeffrey Snover, PowerShell architect. Here's the one I did in November of 2006, for contrast. The project has grown

I think we filmed this in March. In this one I sing the praises of PowerShell and our team at Corillian that wrote "Project Evergreen," a deployment philosophy that turned into our Corillian Member Advantage product. Check the video out. Watch it via Windows Media or download the WMV. I hope you enjoy it.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Six Essential Language Agnostic Programming Books

June 13, '07 Comments [51] Posted in Musings | Programming | Reviews
Sponsored By

A gentleman emailed  thanking me for http://www.hanselman.com/tools, and suggested I make a list of great Programming Books. I don't think it'll be as long as the Tools List, but here's my list. I specifically made the list Language Agnostic. Also, many of these books are by authors who write gold. That means, nearly everything they write is worth taking a look at. I haven't listed every book they've written, in those cases, just their "Greatest Hits."

When it comes to programming languages, I'm not a religious zealot or C# apologist. My religion in these matter is strict Apatheism. I just don't care enough to fight (except for VB people. They're just nuts. (kidding!)) . Pick the language that makes you smile and ships the project. It is for this reason that I prefer to read Language Agnostic Computer Books.

Code Complete - Steve McConnell - Darn near a bible of software development goodness, Code Complete reminds us of our priorities. It's essential and everyone who writes code should read this book. The Pragmatic Programmer - Andrew Hunt and Dave Thomas - I like to read this book at least every six months or so. It's clean, clever, clear and full of concrete tips you can use to be a better, simpler, pragmatic programmer. A new classic. Programming Pearls - Jon Bentley - This may feel initially like a C book, but it's really an algorithms book at its heart. It's old school with techniques and thought problems that can be applied today, even in language like Ruby and C#.
Refactoring - Fowler, Beck, Brant, Opdyke, Roberts - Although the language used is Java, the concepts are universal. This is a very linear, easy to read, learn by example book. If you think you know how to refactor, but you haven't read this book, pick it up and refresh yourself. You'll find names for Refactorings you've used for years and you'll definitely not only pick up new ones, but be better able to spot opportunities to use them. Design of the UNIX Operating System - So few programmers today can answer questions like "explain how virtual memory is managed" or "how are Unix processes different from Windows." How did we get here. Know your history. Design Patterns - Gamma, Helm, Johnson, Vlissides- One of the comments on Amazon says it best, "It is expected that any professional developer has read this book front-to-back. Buy it, read it, then put it in your bathroom and read it when convenient. Also, when you're done, spend some time at the Portland Pattern Repository.

UPDATE: There's some GREAT comments below, and I'm looking into each of them and putting together a list on Amazon.com. I made some pretty obvious gaffes (it was late. ;) ) by not including SICP (Structure and Interpretation of Computer Programs) or TAOCP as well as Types and Programming Languages. A number of folks said the list wasn't very language agnostic because it's very "C" and imperative language focused. Good points all!

What books did I miss, Dear Reader?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Video: Windows Browser Speed Shootout - IE7, Firefox2, Opera9, Safari for Windows Beta 3

June 12, '07 Comments [27] Posted in Musings | Reviews | Tools
Sponsored By
There is a lot of good discussion about the Safari for Windows release and my, as well as others (including Apple's), assertion that it's fast. Or at least it feels fast. A few folks said that it might feel fast because Steve Jobs said it's fast

So, I decided over lunch to do a non-scientific (but using common sense) test. I started by loading up each browser and resizing them to exactly 800x600. I used Camtasia to record them, independently, loading hanselman.com, apple.com, cnn.com, msdn.com, sun.com and craigslist.org.

I then downloaded a free version of Sony Vegas and made a 1600x1200 (four quadrants of 800x600) and put each site's loading in their appropriate quadrant. I started the timer (and start frame) when I press Enter in the Address Bar and stopped it when I saw a "done" indication from the browser. For some that was the word "done" in the Status Bar, for others it was a progress bar finishing and disappearing.

Browser Speed

I did the whole thing, capture and edit in Raw 30fps and didn't make it smaller until the final Render. I deleted browser caches and pre-cached DNS for each. Each browser's file was about 1.2 gigs each.

Here's a table of the results:

  Desc FF2 IE7 Opera9 Safari3
hanselman.com heavy, css, javascript 3.604 5.939 4.872 4.872
apple.com light, lots of images 3.670 4.337 4.27 1.134
cnn.com heavy, javascript, many ads 5.339 2.936 3.337 2.002
msdn.com very heavy 6.74 11.946 12.88 2.67
sun.com light, big image 4.938 1.868 3.336 1.801
craigslist.org very light, nearly all text 1.602 0.868 0.668 0.668

You can check the video for yourself, but the nutshell conclusion for the non-Safari browsers is "it depends on the site," but on my computer, Safari on Windows is not slow. The question is, are you willing to put up with a Mac-like interface, wonky text anti-aliasing and some weird rendering, without your FireFox plugins? I'm going to give it a try and see how it goes. It's a lot to ask.

Also, Craigslist just generally rocks. Enjoy.

Technorati Tags: , , , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Microsoft Silverlight in Safari for Windows

June 11, '07 Comments [14] Posted in Musings | Silverlight
Sponsored By

After I installed Safari for Windows, the second thing I did was see if it would run Silverlight. I loaded up the Airline sample that I had running locally on my machine and got this.

Silverlight Airlines Demo

From this I glean that the JavaScript detection code isn't digging Safari on Windows. So...checking my HTTP UserAgent gives me:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3

...but on Mac it's usually:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/XX (KHTML, like Gecko) Safari/YY

...and since it's not Silverlight but rather the JavaScript that makes the decision on whether to try to load Silverlight (and considering that Flash and what-not worked in Safari without be needing to reinstall any plugins).

I opened up this app's Silverlight.js file and added an alert() around line 85:

var versionStr = detectAgControlVersion();
alert(versionStr);

...and it reported 0.8.5. That means that Safari can see the plugin on the system, but the version should be 0.95.

I figure that the Silverlight Team is already all over this, so rather than solving the problem for them, I added:

agVersion = "0.95.0";

...around line 65 to force the issue. This got Silverlight loaded into memory, as seen in the Process Explorer screenshot below...

Process Explorer - Sysinternals www.sysinternals.com [PDXSHanselm]

...but nothing showed up. Blank screen. No amount of windows jiggling or resizing (to force a paint) would get it going on my system.

UPDATE: Tim Heuer tried the same thing and says the Silverlight Team is on it and that Safari smells like Opera to Silverlight. He also says he was able to get a control to show while I was not.

If this browser is going to get some share (and it likely will with 1 million iTunes downloads a month - they'll likely bundle it virally) then Silverlight support is a must.

Technorati Tags: , , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.