Rants, rambles, news and notes from another geek

It's Official: Ward Cunningham Hired by Eclipse

Wow. I have had the distinct pleasure of working for the last year with Ward Cunningham, creator of wiki and one of the founding fathers of the agile movement. Every meeting with Ward was one of those amazing experiences where you walk away slightly dazed as you slowly realize that he sees the world differently than the rest of us. And that is his genius. He has a gift for seeing the simplest solutions to hard problems.

Any time we had a hard time naming something, a class, an event, a project, anything, Ward would quietly ask questions until he reached the point where he would say, “You knowΓǪ that sounds like aΓǪ”

And you know what? He was right. Every time.

So this morning I was sent this link from EclipseZone.com announcing that Ward is going to be joining the Eclipse Foundation. I know Ward will do well there and I’m sure they will recognize and utilize Ward’s genius in their work.

Ward, we&nbsp_place_holder;are sorry to see you go and we will all miss you dearly. Best of luck in your new endeavors. Please stay in touch.

Life Is Better With...

ΓǪCold Stone Creamery’s Cake Batter Ice Cream.

It’s back. And it is just as good as it was before.

Begone Pagefile: Hello Perf and Battery Life

Have you ever looked at your system’s memory usage? I mean really looked at it? These days most geeks have systems that have at least 1GB RAM if not more and&nbsp_place_holder;this got me to wonderin’ΓǪ do I really need a pagefile if I have enough RAM?

I remembered hearing people talk about not needing one much past 768MB RAM, but I hadn’t ever tried it. Until last week. I happened to get a memory upgrade for my laptop (up&nbsp_place_holder;to 2GB RAM) and thought, “What the hell? This is as good a time as any to try this.”

So I told XP to run with “No paging file” (System Properties => Performance Options => Advanced => Virtual Memory) and shut down the system. I then added my new RAM and booted up. Right off the bat I noticed the performance difference. Everything seems snappier. Application startup times are better. Responsiveness is better.

On Thursday, after doing all this,&nbsp_place_holder;I said to Brad and Ed, “Guys, I’m running without a pagefile and it is great.” You know what they said back? “Duh! I run without one too.” Okay, perhaps I’m last to this party, but I did a bit of digging and didn’t seem to find many people talking about this. Why? I have no idea.

Now that I’ve been running for a few days this way, I wanted to share a few other interesting observations.

First of all, I’ve noticed that the system is quieter. I’ve been sick since Friday so I’ve been doing a lot of laying in bed watching TV with my laptop sitting on the table next to me. And I’ve noticed that the fans don’t run as often as they used to. And the system seems cooler overall. Must be because the drives aren’t so busy.

The other thing I’ve noticed is that I seem to be getting better battery life. Again, this is purely anecdotal, I don’t have any hard numbers for you, but it sure seems like I’m getting 50% more life out of the battery than I used to get. Again, I’m guessing that it is because I’m not spending power spinning drives and fans as much as I used to.

Anyway, I just wanted to share this with you all. YMMV.

Also, for those of you who claim that it doesn’t work with “heavy” apps, I’ve been happily running Outlook, Visual Studio 2005, Word, Excel and multiple instances of IE all at the same time and my memory usage never seems to max out.


Geek Notes 2005-10-15

Since repaving my computer I haven’t installed an RSS aggregator so I haven’t been reading many blogs. This has been both good and bad. Good because it has allowed me to focus on CAB and bad because I’ve been falling out of touch with my normal sources of information: blogs.

So today I went ahead and installed my preferred RSS aggregator: Omea Reader.

  • Kids Programming Language - This is an interesting language. Designed to be easy to learn but teach real world programming concepts with a simple but helpful IDE. Cool. It is written in .NET and can convert the KPL code into C# or VB.NET with a button click.
  • Stay Away From World of WarCraft - Apparently their new EULA allows them to scan your harddriv for whatever they want (under the guise of looking for cheating tools) and send the information back to Blizzard. No thanks!
  • Let’s All Write a Cmdlet Part 1 - Adam Barr shows how simple it is to extend the Monad world with new Cmdlets written in .NET. When you’re done with Part 1, read Part 2. Also, for all you Monad heads out there, go get the Documentation Pack.
  • System.Collections.ObjectModel.KeyedCollection - HmmmΓǪ I think I was looking for something just like this a few weeks ago while fixing something in CAB. Damn the BCL is just too big sometimes!
  • Candle Making - Very cool. I love finding new metaphors to explain agile development and this is the best new one I’ve seen in&nbsp_place_holder;a while.
  • Chris Anderson is a Closet TDDer? - Apparently in the new Framework Design Guidelines book there is a plalce where chrisan actually hints that something like TDD is probably the&nbsp_place_holder;best way to spec/design an API. Well, DUH!

CAB June to October: Whither Private Field Injection?

As I’m sure you can imagine, we were given lots of feedback from the June CTP of CAB. One of the things we heard about, both from within MS and from outside folks, was that doing manipulation of private fields or properties was bad and that we shouldn’t support doing dependency injection into privates.

Additionally, in .NET&nbsp_place_holder;the permission that allows private reflection&nbsp_place_holder;is limited&nbsp_place_holder;to only those assemblies running with Full Trust. Which means that those running in the LocalIntranet or Internet zones can’t do it. It also turns out that private reflection causes a pretty severe performance hit.

So we decided to go to public injection only.

This led us to the question about whether to support fields at all. According to the .NET Framework Design Guidelines for Class Library Developers, it is recommended that fields not be exposed publicly to better enable versioning and maintenance of the class. Instead, it is recommended that if the data is meant to be get/set from outside the class it should be wrapped in a property. So as a result, we decided to discontinue support for field injection.

But what about those times when you don’t want the property to be set by users of this class? How do we allow for injection of it, while not allowing unwanted manipulation of its contents by consumers of the class? Almost everyone who wanted to do private field injection sited something like this as the reason for wanting to keep it private.

That is why the dependency attributes now support being applied to parameters. You see, we now support constructor dependency injection. So when you have a situation when you want a field to get set once and only once, instead of doing dependency injection into a private field, we now recommend that you take that dependency injection via a constructor parameter.

So whereas you would have had something like this in June CAB:

   1:  public class MyClass

   2:  {

   3:      [ServiceDependency]

   4:      private ISomeService service;

   5:  &nbsp_place_holder;

   6:      public MyClass()

   7:      {

   8:      }

   9:  &nbsp_place_holder;

  10:      // Etc.

  11:  }

In Oct CAB, we would do it like this:

   1:  public class MyClass

   2:  {

   3:      private ISomeService service;

   4:  &nbsp_place_holder;

   5:      public MyClass([ServiceDependency] ISomeService service)

   6:      {

   7:          this.service = service;

   8:      }

   9:  &nbsp_place_holder;

  10:      // Etc.

  11:  }

If you need to be able to support multiple constructors, we have a special attribute called [InjectionConstructor] that you can apply to the one you want us to use:

   1:  public class MyClass

   2:  {

   3:      private ISomeService service;

   4:  &nbsp_place_holder;

   5:      public MyClass()

   6:      {

   7:          service = new DefaultServiceImplementation();

   8:      }

   9:  &nbsp_place_holder;

  10:      [InjectionConstructor]

  11:      public MyClass([ServiceDependency] ISomeService service)

  12:      {

  13:          this.service = service;

  14:      }

  15:  &nbsp_place_holder;

  16:  }

In the end, you get the same thing: an instance of MyClass that gets its service field set. But in the newer code, you control how that private field gets set (as it should be) and we just make sure you get the right value for it.

We think that this results in a class that is clearer, easier to test, and doesn’t cause problems that can crop up when you do private reflection.

But as always, we’d love to hear what you think of this.

Prefactoring == BUFD?

Darrell Norton blogged about a new book from O’Reilly called Prefactoring. From the Editorial Review on Amazon:

More often than not, developers will stop a large project in the middle of the build stage to rethink and recode the software design so it’s cleaner and more efficient. Known as “refactoring,” this process eats up valuable time and money. To help offset refactoring, this book presents a new process called “prefactoring,” the premise of which states that you’re better off considering the best possible design patterns before you even begin your project.
Prefactoring, in essence, is the art of applying the insights gleaned from previous experience (whether yours or someone else’s) when developing software to new projects. Doing so will likely save you from making costly design changes midstream–and maybe even save your job!

This practical, thought-provoking guide details prefactoring guidelines in design, code, and testing, each derived from the lessons of many developers over many years. With these guidelines, you’re far more likely to create more readable and maintainable code before you reach the second-guessing stage.

To help communicate the many facets of this process, Prefactoring follows the example of a fictitious client, Sam, as he seeks to create a software system from beginning to implementation. Among the topics covered:

  • General development issues
  • Implementation classes
  • Object-oriented design
  • Creating reports via separation of concerns
  • Associations and states
  • Creating and testing interfaces

If you understand object-oriented design, and you want to save time and money by considering more efficient designs before you begin your project, Prefactoring will show you the way. It won’t guarantee that you’ll never need to refactor your design or code again, but you’re sure to cut down on the amount of refactoring you do.

Oh my lord! Where to begin?

I’ve seen a few people review this book who claim that it isn’t actually about Big Up Front Design (aka BUFD, BDUF, BFUD, whatever), but this editorial summary certainly is advertising a BUFD approach. It is presenting confusing FUD (Fear, Uncertainty and Doubt) about one of the most fundamental software development techniques we have: Refactoring.

I suspect that the real approach being suggested here is to use your brain and experience to avoid being an idiot. But seriously, that’s what separates those who deserve to get paid and those who should change careers.

The first two lines in particular&nbsp_place_holder;bug the shit out of&nbsp_place_holder;me:

More often than not, developers will stop a large project in the middle of the build stage to rethink and recode the software design so it’s cleaner and more efficient. Known as “refactoring,” this process eats up valuable time and money.

This is NOT refactoring you schmuck!

Refactoring is a tool for adjusting the design of existing code, without changing what the code does. It doesn’t “eat up time” because it doesn’t take a lot of time. This is another one of those problems where the consistent misuse of a word changes its meaning. I constantly hear people talking about “taking some time off and refactoring that module” or “refactoring the architecture”.

These people have obviously not read Martin Fowler’s book Refactoring: Improving the Design of Existing Code.

As Martin makes very clear, refactoring is about taking very controlled small steps. It is not about redesigning a whole layer or subsystem “just for fun”. You do it when you need to make space for a new feature. You do it when the code you just wrote needs to be cleaned up before checking it in and moving on. You do it in 5 or 10 minutes. Anything more than that isn’t refactoring. It is redesign.

Please peopleΓǪ when you mean redesign, say that. When you mean refactoring, say that. Don’t ruin yet another word. As for “prefactoring”, my suggesting is to just use your brain, write good code, do the right thingΓǪ and don’t buy this book.

CAB: Migrating From June CTP to October CTP

Members of the CAB team have started posting about specific things you will want to know if you are migrating&nbsp_place_holder;your code from the June 30 CAB CTP to the new October 2005 CTP that we released on Friday. Here’s a list of what’s up there so far. I’ll come back and update this page when anyone posts any other useful migration information, so keep checking back.

Brad Wilson:

  • The Big Changes to WorkItem&nbsp_place_holder;- WorkItem was basically re-writtenΓǪ here’s a stab at the most important changes to the surface API.
  • Goodbye, Application Host!&nbsp_place_holder;- It’s official. No more application host. Here’s why and what we now have instead.
  • CabApplication and Family&nbsp_place_holder;- CAB now has a framework of application classes that you use to get your CAB application booted up
  • Development Tools&nbsp_place_holder;- A brief explanation of the different versions of VS, NUnit, etc. that work with each release

Ed Jezierski:

  • WorkItem Extensions&nbsp_place_holder;- Ed talks about how to extend someone else’s WorkItem with the new WorkItemExtension stuff.

John Luif

Peter Provost

Unix => MSH Translations: Find and Grep

I’m sure some of the cool folks over on the MSH team have better ways to do some of these things, but I wanted to share some of the ones I use all the time.

Everyone who works on a UNIX system for very long learns how to get the find command to work for them. If you install the Unix Tools package for Win32, you can have find on your Windows machine. Then, to use it to look for all occurrances of all C# files below the current directory, you would do something like this:

MSH:1 > find . -name *.cs -print

It turns out that find has tons of other options, but 9 times out of 10, what you do is just what I showed.

Now to do that in MSH requires a little more typing, but it easier to customize, and in my mind, it is easier to a) figure out what to do and b) figure out how to change things:

MSH:2 > get-childitem -recurse where { $_.Name -like “*.cs” }

But there is actually a shorter way to do this:

MSH:3 > get-childitem -include *.cs -recurse

And, in fact, this can be made even shorter when you use the default aliases and the fact that cmdlets only require enough of the switch to make it unique:

MSH:4 > gci -i *.cs -r

Which is really not any longer than the original find form. All four of those options produce exactly the same output. As with most things in computers, it is a balance between clarity and simplicity. Number 4 is nice and short and very simple, but it isn’t as clear as #2. You decide which you prefer.

Now suppose you aren’t just looking for C# files, but you are looking for all C# files that have the string “using System.Configuration” in them. I can take any of #2, #3 or #4 from above and pipe it into the match-string cmdlet. I’ll go ahead and take the short form (#4):

MSH:5 > gci -i *.cs -r match-string “using System.Configuration;”

Now, on my system I have an alias named “grep” that points to “match-string”, so I actually do it like this:

MSH:6 > gci -i *.cs -r grep “using System.Configuration”

Not bad, eh? I use this kind of search almost every day. I never use the Windows Explorer “SearchΓǪ” thingy anymore–you know, the one with the dog? This is just so much faster to use.

Before I end, one other thing that is interesting is to see how quickly you can start to combine these things to ask different questions. Suppose your project manager comes and asks you, “How many lines of C# code do we have in the project?” First, let me show you how to get the count of C# files:

MSH:7 > (gci -i *.cs -r).Count

That’s cool, but not the answer we wanted. We want the number of lines of code. Now, for simplicity lets assume that “lines of code” means something simple like “non-blank lines that don’t start with two slashes.” That may not be 100% accurate, but it is certainly close enough for a swag answer.

First of all, I had to figure out the regex for this. I decided to skip the “non-blank” part in the regex and instead focus on the part about “lines that don’t start with two slashes”.

That got me this regex, which I went ahead and stored off into a variable called $re:

MSH:8 > $re = “^((?!\s//.).)*$”

This basically says “all lines that don’t start with whitespace zero or more times followed by two slashes followed by anything up to the end of the line. (FWIW, there’s a part of my that thinks this regex has one too many dots but I can’t seem to make it work without them.)

Now we can combine this with what we did above to count the lines that don’t match the regex:

MSH:9 > (gci -i *.cs -r grep $re).Count

But we forgot to filter out the blank lines! Oops. Since I couldn’t figure out how to do that in the regex, I did it with a where clause on the pipeline:

MSH:10 > (gci -i *.cs -r grep $re where-object { $_.Line.Trim() -ne “” }).Count

Pow! That works.

But man, that was a crappy think to type in wasn’t it. So let’s save it off into a script file that we can reuse later. Just copy these three lines into a file called linecount.msh and put it somewhere on your path.

   1:  param ( [string] $match="*.cs" )

   2:  $re = "^((?!\s*//.*).)*$"

   3:  (get-childitem -i $match -r | grep $re | where-object { $_.Line.Trim() -ne "" }).Count

Again, I don’t promise that this is perfect, just what I’ve been using lately.


CAB October 2005 CTP Now Available

On Friday we released the October 2005 CTP of the Composite UI Application Block to the GDN Community Site. Go get the bits from the Download Page and let us know what you think.

We’ve changed a number of things based on customer feedback from the June drop and we really think it is better. This version is based on .NET 2.0 RC (aka version 2.0.50727.26), so make sure you have the right framework bits installed before trying to build it. (You can get information about downloading the Release Candidate from MSDN.)

Finally, expect a number of posts from me and Brad (and others I’m sure) about the cool new stuff in there, especially the changes since the June release and details on the Object Builder dependency injection framework.


Machine Repave Trials and Tribulations

I’ve always both loved and hated repaving my machine.&nbsp_place_holder;I love doing it a few times a year because it lets me start from scratch. It is like going through your closet or your garage and just throwing everything away. It feels good. It let’s you get back to just those things that you actually need. No extra crap in the way.

But, like with your closet or your garage, it is also painful. But for me the pain is different. When you do a “purge” of your physical stuff the pain is when you have to go through each thing and look at it, turn it over, think about the last time you used it and decide if you really need it anymore. When I repave my laptop, I basically just have to backup my profile (e.g. My Documents) and then reformat. Instead of pain on the purge side, there is pain on the repave side.

The pain comes with all the stuff I have to install to get back to a good place. Which is what I discovered on Monday when I decided to do it again.

The backup part went fairly well. I used xcopy to back up my profile to my external disk, then used the F12 RIS boot installer to pick up a nice fresh Windows XP SP2 install. The MS IT folks have a nice little system for this that walks you though a series of questions and when it is all done, you have your OS, Office, Anti-virus, RAS connectivity, etc. all ready to go.

Which, as I indicated before, is where the pain starts. The first thing that hurt was when I realized that I lost my most current archive.pst and personal.pst&nbsp_place_holder;because I forgot to make sure Outlook was completely shutdown before doing my xcopy. Which means the opened (and locked) PST files were skipped. And I also wasn’t careful enough about reading the list of skipped files that xcopy produced.

No biggie though, by the time mail gets into my archive, I generally don’t need it anymore, I just keep it in an attempt to be more organized an anal. The personal.pst file is a bit more annoying, not because I lost anything, but because I’ll have to regenerate it. You see, my personal.pst file was a carefully re-organized merging of four pst files from previous lives. Old emails, software registration codes, etc. I still have all of the old pst files, but I’m gonna have to re-merge them. Ugh. I just did it a week or so ago (hence no backup) and now I have to do it again.

Then comes the next pain. This is the one I expected: Installing all the software that I use to do my job (and have a little bit of fun too). I decided to fire up&nbsp_place_holder;a OneNote doc and keep track of everything I installed in roughly the order I installed it. This list isn’t complete however, because I take an agile approach to building my computer. I install things only when I need them. I’m sure over the coming weeks I will be installing more, but this is what I have installed over the past 3 days.

Update 2005-09-26 - Installed more stuff this weekend: