Freigeben über


Parting words for dear friends

I have a few thoughts that I'd like to express about Microsoft's software development before I go.

Clearest code wins.

Most developers at Microsoft haven't yet learned the incredible value of writing the clearest code possible.  Once I saw a someone make a checkin that added 200 lines in the middle of a 600 line function. I'm thinking it was already about 597 lines too long.  Use Extract Method to break them in to bit-sized chunks.  Use Extract Class to manage the plethora of methods you suddenly produce.  Don't stop there.

OO isn't a fad

Microsoft has pushed hard over the last ~5 years to make its software secure.  Security is hard, but there's no reason to make it harder.  For example, countless security issues came down to buffer overruns in C++ code where a buffer was passed without a corresponding length.  The response?  Let's write tools that help you find places you pass buffers, and make sure you pass a length along side. 

Hey, when you find yourself passing two or more values around together, why not put them in to a class?  Just start there.  Polymorhism, inheritance, and encapsulation can come later. 

(Hey Windows: I'm looking at you!)

It's OK to use someone else's code

At one point, the Visual Studio code base had about a dozen implementations of a C++ String class, most of them hacked out of MFC.  That's a vast improvement over passing the buffers around, but hey... these library writers are paid to work on these things full time!   Why aren't you using STL or ATL yet?

This isn't just in C++... in the original implementation of the .Net Framework, there were countless implentations of hash tables. Woah, guys!  Let's get some libraries!

Design your problems away

Every time you run in to a problem, step back & ask "How can I make sure this never, ever happens again?" 

Got buffer overruns?  Using a buffer class makes them go away.  Having trouble with refcounts? Try CComPtr.  Is your cache getting corrupted?  Remove it, or encapsulate it. 

When we did this in my last C++ project, we found our C++ code started to look remarkably like C#.  That's a clue: C# has already designed away most of the tedium of C++.

Most importantly: we can do better.  

The above complaints are specific, local issues.  In time they can be addressed indivdually, and this blog post will become obsolete.  But there's one thing that Microsoft developers should always be working on: doing their job better.  Ask yourself questions like:

  • "How can I make sure this problem goes away forever?" 
  • "How can I produce fewer bugs?"
  • "How can I make it easier to fix the bugs I have?"
  • "How can I make it easier to respond to change quickly?"
  • "How can I make it easier to make my software fast enough?"

I once managed a team that did this very well.  They were largely new hires, mostly straight out of college.  But after a year, they were rocking.  They produced features faster, had fewer bugs, fixed bugs faster, and reliably beat the schedule every time.  They far outperformed teams of experienced developers working on familiar code bases, often with well-understood problems.  It was amazing.

EDIT: I wish I could have addressed these issues while I was at Microsoft, but that's hard, and I wasn't successful.  This blog post is about the last chance I have to do anything here; now it's up to you to decide if you can use this.

Comments

  • Anonymous
    November 09, 2007
    It's Jay Bazuzi's last day at Microsoft to become a stay-at-home dad . At one point Jay was development

  • Anonymous
    November 24, 2007
    As he mentions , maybe he could have fixed these whilst he was there - but I doubt it. Now that he has

  • Anonymous
    November 24, 2007
    A development lead that's leaving Microsoft provides parting words that pertain to many development groups. A good read, and it's a fun glimpse into a small part of Microsoft. They certainly aren't the only company that has problems like this,...

  • Anonymous
    November 27, 2007
    Martin Fowler is currently working on a book in reference to DSL, Domain Specific Languages. A...

  • Anonymous
    November 29, 2007
    JayBazuzi曾任C#编辑器的开发主管,现正离开微软。他在离开之前令人惊讶地给旧日伙伴留下了一些尖锐的临别赠言:

  • Anonymous
    December 30, 2007
    看到了C#的编辑器开发主管离开微软时写的PartingWords,列举了很多他看不惯也没有办法解决的事情,比如著名的缓冲区溢出,相同功能的方法写了几十个.看来不光是我们这些IT民工写的代码,自己不满...

  • Anonymous
    August 04, 2008
    微软开发主管临别诤言 作者NiclasNilsson译者郭晓刚发布于2007年11月28日下午6时54分...