Scott Hanselman

How do you organize your code?

April 1, '05 Comments [10] Posted in ASP.NET | Corillian | NUnit | NCover | Nant | Tools
Sponsored By

Organizedfolders1How do we organize our code? Well, it all depends on the project and what we're trying to accomplish. We're also always learning. Our big C++ app builds differently than our lightweight C# stuff. However, for the most part we start with some basic first principles.

  • A repeatable build
    • Obvious, maybe, but if you can't build it n times and get the same result, you may have some problems.
  • Continuous Integration
    • When possible and appropriate, have builds automated and build mail sent out.
    • We started with building on every check-in, and for the most part we do that.
    • We added a daily build, so now we will build on every check-in, but there's a 5pm build also.
  • Tools
    • CruiseControl.NET - the goal being a company-wide dashboard.
    • NAnt -building
    • NUnit - testing
    • NCover - code coverage, not formalized yet.
    • FxCop - For the obvious stuff, CLS compliance, etc.
    • NDoc - the shiznit. Use it to automate CHM file creation. That auto-generated CHM is then sucked into a larger 'prose' CHM.
    • libcheck - looking into it. Using it to measure API churn.

As far as layout (picture above), there's no right way. We've got folks who've been doing builds since before Windows, so we have a little *nix-y style in a few things. Again, if it works, use it. I like:

  • source - for source. duh.
  • tools - This CVS module is the source for any tools/utils the project needs. Shared between projects.
  • install - XCopy deployment, it'd be nice. We do versioned MSIs for everything significant.
  • test - Not Unit-tests per se, mostly larger projects for integration and regression testing.

As far as the build directory is concerned:

Organizedfolders3

Everything under build is 'important.' It kind of speaks for itself. Bin for bins, doc for the CHM.

In source, we have:

Organizedfolders2

Every 'subsystem' has a folder, and usally (not always) a Subsystem is a bigger namespace. In this picture there's "Common" and it might have 5 projects under it. There's a peer Common.Test. Under CodeGeneration, for example, there's 14 projects. Seven are sub-projects within the CodeGeneration subsystem, and seven are the NUnit tests for each. The reason that you see Common and Common.Test at this stuff is that they are the 'highest." But the pattern follows as you traverse the depths. Each subsystem has it's own NAnt build file, and these are used by the primary default.build.

In this souce directory we've got things like build.bat and buildpatch.bat. The goal being that folks can get the stuff from source control and type BUILD and be somewhere useful. It's VERY comforting to be able to reliably and simply build an entire system. Recently I had to patch something I'd worked on 18 months ago, but that had used this principal. I did a Fet, did a BUILD and I was cool. We then used reflector and Assembly Diff to confirm that the patch surface area was minimal.

We DO build things in VS.NET, but for the vast majority of projects, we prefer a command-line build to get real repeatabilty. With .user files and per-user reference paths, I just don't trust VS.NET to do the right thing.

Junctions

Another thing we make a lot of use of are what we call Junctions. These are NTFS Reparse Points, also known as symlinks.

Organizedfolders4

In this screenshot of a standard DIR from the command prompt, directories show up as <DIR> while junctions say <JUNCTION>. These junctions point to other directories. But NTFS makes it transparent; you can CD into them, and even Explorer has no clue. Certainly, they can be dangerous, as you can clean out a directory and not realize that it's the authoritative source for something and is being referenced by other projects.

Organizedfolders5

You can download Junction from SysInternals. You can also use LINKD, that shipped with the Windows 2000 Resource Kit. In this screen shot, the relative SDK folder points to an installed version of our SDK. This allows our CSPROJ files to refer to our assemblies with relative paths, gives developers a lot more flexibilty, and makes the NAnt builds simpler.

It also allows us to swap out different versions of things. For example, I could point the SDK folder to a previous (or future!) build of the SDK and build again. This flexibility comes with a cost though - complexity. People have to think a little more. Fortunately, our build guys are pretty savvy and will (shell script-like) go looking for preferred versions of things in standard locations and set up Junctions for folks. 

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

Quotes of the Day - March, 31, 2005

March 31, '05 Comments [2] Posted in Musings
Sponsored By

"Sure, our software interoperates. It interoperates the same way the U.S. does in Iraq."

"Dude, you're playing Jenga with our Object Model."

"I don't like the whole [ServiceContract] attribute. It's too loose. How about ServiceEdict? ServiceFatwa? ServiceDogma?"

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

Brainstorming Hardware Projects

March 31, '05 Comments [14] Posted in Web Services
Sponsored By

I'm looking to do some hardware/gadget related projects and articles in .NET.

Brainstorm with me...

  • An X10 clickable floorplan of your home for use as a 10ft interface in Windows Media Center
  • A USB video monitor window for watching the front door or babies. Pop it up when movement is detected? Perhaps use Windows Image Acquisition.
  • An interface and charting/graphing application for my Blood Sugar meter. Perhaps set it up for any medical device with values over time.
  • Live GPS tracking that reports my position to a blog as I move.
  • Lego Mindstorm Robot with .NET?
  • Hook up to the monitor port of a car (the one the auto techs use) and dump the collected internal logs.
  • An Outlook Calendar Provider that shows a new Calendar with blood sugar (or blood pressure, etc) data pulled from a device and stored in another file.
  • A UPnP client in .NET
  • Something with a .NET CPU - Ideas?
  • Report Continuous Integration build status to a SPOT Watch
  • Something with the Windows Fingerprint Reader?
  • Get a CueCat or BarCode Scanner to catalog all my books using Amazon.com Web Services.

More ideas?

 

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

Internationalization Support in Windows XP

March 31, '05 Comments [5] Posted in Musings | Tools
Sponsored By

A good reminder from Michael Kaplan on international support in Windows.

One of the first things I do when I install any english version if Windows is to head to Control Panel|Regional and Language Options and tick these two checkboxes. It's a great way to get right of those pesky black squares.

Michael reminds folks that:

"Every version of Windows 2000, Windows XP Home, Windows XP Professional, and Windows Server 2003 contains all of the international support"

I've got lots of friends who's parent or parent would really prefer to surf and email in their native language, and they don't realize their language may be a checkbox or font away.

That said, here's Google in Zulu: http://www.google.com/intl/zu/

P.S. Some folks don't realize that the reason folks says "i18n" is because there's eighteen letters between the i and n in internationalization. ;)

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

TechEd Video #3 - Drink the TechEd KoolAid

March 30, '05 Comments [8] Posted in Movies | TechEd | Javascript | Speaking
Sponsored By

Rory and I love Microsoft. Rory drank the Kool Aid, but I'm not so sure. Maybe with the help of Dan Fernandez, Becky Dias, Simon Guest, Shy Cohen, Richard Turner, Rory's Girlfriend and Jay Roxe.

Please spread it around and Trackback/Pingback it. If you can't view it below, you can download it here.

Remember, if you're blogging TechEd this year, make sure to register your blog at TechEd Bloggers.NET and get your content aggregated!


play video stop video indicatorhandleamount downloaded toggle sound launch in external player
Launch the streaming media file

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.