Browsing Posts in .NET General

My good friend and fellow plumber, John Bristowe, is on the road again, this time with the third installment of Microsoft Canada’s DNIC Tour. He’ll be in Calgary talking about how to incorporate the .NET Framework into your existing applications.

Date: Thursday, September 27, 2007 from 5:30 PM – 7:30 PM
Location: Nexen Conference Centre Theatre, +15 Level
Registration: http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032353126

 

Developer Night in Canada

Developer Night in Canada (DNIC) III – Bringing the Power of the .NET Framework to Your Existing Application

For the past few years, you’ve heard a lot about the .NET Framework and the development platform it provides to foster innovation. Meanwhile, you’re still managing applications written with thousands of line of VB 6.0 code and you’d give anything to move to a more modern development environment and platform.  In this event, we’ll walk you through real-world tips & tricks that you can use to bring your solution to the .NET Framework. Specifically, you’ll learn how to tackle the issues of integration and migration when dealing with legacy applications. We’ll also feature folks from the Canadian developer community to provide you their experiences and insights.

I was recently asked, “What is the real story behind the name of C#?” Let’s take a quick stroll down memory lane and on the way we’ll answer that question…

In the beginning – around 1997 – there was Project Lightning. I was also known as Project 42 because DevDiv (Microsoft’s Developer Division) lived (and still lives) in Building 42 on the Redmond Campus. (I’ve always thought that was an awesome building number for DevDiv with the little hat tip to Douglas Adams’ Hitchhikers Guide to the Galaxy. I’ve always wondered if it was intentional.) Early press announcements referred to it as “Next Generation Windows Services”. Eventually Project Lightning was dubbed Microsoft .NET, though some code names have been forever baked into the system.

Marketing was thinking of calling it COM+ 2.0 or the Universal Runtime (URT). Another idea was the COM Object Runtime (COR). Hence mscorlib.dll, which is still the assembly that holds the CLR’s main types and is the one assembly that must be loaded in every .NET app domain. (System.dll is often loaded, but need not be. Mscorlib.dll contains the code for System.String, System.Int32, etc. You honestly can’t do anything without mscorlib.dll loaded.)

Another code name that lives on today is in the Assembly Binding Log Viewer – fuslogvw.exe - which allows you to monitor the loading of assemblies into app domain – successes as well as failures. (If you’re ever having problems figuring out why the wrong assembly is being loaded, where a particular assembly is being loaded from, or why assembly loading fails, the Assembly Binding Log Viewer is the tool to use. It ships with the .NET SDK.) Now why is it called fuslogvw.exe? Fusion was the codename of the CLR Loader, which is responsible for loading assemblies into app domains. I still think that Fusion is a most appropriate name for a loader.

So back to the original question of the origins of C#. The codename of C# was Project Cool, which was rumoured to be a clean-room implementation of Java. This was back in the days when Sun was suing Microsoft over bastardizing the Java language. As I recall, Sun didn’t like the Microsoft-specific extensions in J++, which allowed it to interoperate with COM. So where did the name C# come from?

C# name was musically inspired. It is a C-style language that is a step above C/C++, where sharp (#) means a semi-tone above the note. (Being a musician myself, I think this is awfully fun.) Back when .NET made its debut, an amusing quip from the Linux crowd was to refer to C# as Db (D-flat), which is the same note as C#, but has different connotations. Two MS Research languages also bear musically-related names: Polyphonic C# and F#.

I hope you enjoyed this trip down C#/.NET memory lane.

Thanks to everyone who came out for the session to listen to tales of the NHibernate Mafia and how persistence ignorance can improve your domain model. Here is a list of recommended resources:

You can download the code here. NHibernatingNorthwind is adapted from code by Oren Eini. I haven’t included the NHibernate binaries. Download and extract NHibernate 1.2 into ..\tools\NHibernate.

If you have any questions, please don’t hesitate to email me or leave a comment.

The website is now live and accepting registrations. We’re accepting 100 lucky participants to take part in this unique event. Sign up now at http://www.altnetconf.com. If you don’t know what I’m talking about, go back and read this. Hope to see you there!!!

Coming to an Edmonton library near you… One night only…

How does NHibernate enable a persistence ignorant domain model? Why would you want a persistence ignorant domain model? Why does the NHibernate Mafia feel so strongly about persistence ignorant domain models? And who are the NHibernate Mafia anyway? This session will answer all these questions and more.

Date/time: Thursday, August 23, 2007 starting at 5:30pm
Location: Stanley A. Milner library (7 Sir Winston Churchill Square)

You can sign up on the EDMUG website.

Coming to Austin, TX… October 5-7, 2007… Brought to you by the NHibernate Mafia themselves… 3 days of ALT.NET mayhem… See behaviours twisted, tests tortured, dependencies injected, object-relations mapped, and DSLs like you’ve never seen them before…

More seriously, what exactly is ALT.NET? David Laribee coined the term to describe developers who look outside the “official gospel” for ideas of how to develop software better.

  1. You’re the type of developer who uses what works while keeping an eye out for a better way.
  2. You reach outside the mainstream to adopt the best of any community: Open Source, Agile, Java, Ruby, etc.
  3. You’re not content with the status quo. Things can always be better expressed, more elegant and simple, more mutable, higher quality, etc.
  4. You know tools are great, but they only take you so far. It’s the principles and knowledge that really matter. The best tools are those that embed the knowledge and encourage the principles (e.g. ReSharper.)

Scott Bellware has assembled an all-star organizing committee, including:

The conference will be run in an open space format, which is very agile in nature and execution. Fundamentally OpenSpace is a conference with self-organizing sessions. If you have an idea for a session, you post it on the schedule. If you see a session that interests you, you show up. If that session sparks an idea you’d like to talk about, post your new session on the schedule. Lather, rinse, repeat… This will be my first time participating in an OpenSpace conference, but I’m excited by the concept.

You can expect topics covering:

  • Software design
  • Testing strategies and continuous integration
  • Test-Driven Development (TDD)
  • Behaviour-Driven Development (BDD)
  • Domain-Driven Development (DDD)
  • Domain-specific languages (DSLs)
  • Object-relational mapping (OR/M) using NHibernate
  • Dependency injection with Castle Windsor
  • Web development with MonoRail
  • Agile team practices, such as XP and Scrum
  • Plus anything else that attendees want to discuss

The Important Stuff

Cost: FREE! (except for the cost of airfare and accommodations)
Location: St. Edwards University Professional Education Center, Austin, TX
Date: Friday, October 5th, 2007 @ 5pm to Sunday, October 8th, 2007 @ noon
Attendance: 100 (max)
Registration: http://www.altnetconf.com

If you are interested in attending the event or would like to know more, please don’t hesitate to contact me or one of the other organizers.

Thanks to everyone for attending Simple Patterns for Simple Problems last week. Source code – before and after – can be found here.* The “after” source is where we left off. The additional Utility methods are left as an exercise for you, dear reader. If you have any suggestions on how to improve this presentation in the future, I would love to hear from you.

* I haven’t included NUnit in the zip file as that would have bloated the download. Once you unzip, simply copy NUnit-Net-2.0 2.2.8\bin to SimplePatternsForSimpleProblems-[Before|After]\tools\NUnit.

After my presentation yesterday on Simple Patterns for Simple Problems, John Bristowe, a fellow plumber (and closet agilist), interviewed me about agile development on the .NET platform. We talked about why developers should be interested in learning more about agile development techniques, including unit testing, TDD, code coverage, continuous integration, and more. Check it out: A Chat with James Kovacs on Agile Development.

UPDATE: One thing I forgot to note was that when I said most agile developers use Visual Studio and ReSharper, I should have qualified that with most agile developers [on the .NET/Windows platform] use Visual Studio and ReSharper, though I’m sure that was obvious. Java and Ruby developers don’t typically use Visual Studio. Tongue out

I know C# quite well and thought I knew all the language features, both old, new, and forthcoming. Today I was completely surprised when I discovered a feature that has existed since C# 1.0 that I never knew about… String literals in C# can span multiple source lines!

My voyage to discovery started when reading a post by Oren Eini about an unrelated subject. He casually mentioned his annoyance that Microsoft used string concatenation in its examples and why weren’t they using multi-line strings. Oren is a smart guy and generally knows what he’s talking about. So I started poking around. The following code results in a compiler error, as I expected:

string sql = "SELECT foo
              FROM bar
              WHERE baz=42";

So regular strings cannot span multiple lines, which is why you commonly see it written as:

string sql = "SELECT foo " + 
             "FROM bar " +
             "WHERE baz=42";

I can wax poetic all day about the advantages/disadvantages of hard-coded SQL in your code. The reality is that if you’re not using an object-relational mapper (such as NHibernate - and you really should be), you need to stick the SQL somewhere. Code is as good a place as any. The truly awful part is round-tripping the SQL between a query editor and C# for tuning or investigation purposes because you have to strip out all those double-quotes and plus signs. But C# has another type of string — the string literal (@”"). As it turns out, string literals can span multiple lines. The following is completely valid C# and even provides decent readability of the SQL in your C# code:

string sql = @"SELECT foo
               FROM bar
               WHERE baz=42";

Maybe LINQ (in .NET 3.5) will do away with the need for SQL in quoted strings, but until that day, my SQL statements became a little bit more wieldy.

My MSDN Magazine article entitled Debug Leaky Apps: Identify and Prevent Memory Leaks in Managed Code has been published in the January 2007 issue. Go check it out!

Due to space constraints, the editors at MSDN Magazine left a few acknowledgements on the cutting room floor. I would like to acknowledge Rico Mariani (MS) for coining the term “midlife crisis” as it applies to the garbage collector. His blog is full of excellent perf advice and insight. I would also like to acknowledge Tess Ferrandez (MS) as one of the examples in the article is based on her blog post, “Does Page.Cache leak memory?“.

Finally, a very special thanks to my spouse, Risa Kawchuk, for her patience and excellent editing of the many versions of the manuscript.