Windows SysInternals

Wow! Where to begin?

Windows SysInternals is a free set of command-line and Windows utilities from Microsoft. There are so many of them, and they are so varied, that it’s impossible for me to cover all of them here. So, I guess I’ll pull out a few of my favorites to talk about. But, you should really go get the entire set of the tools, as soon as possible!

(Much of the text that follows is pinched from the Microsoft site. My comments are in italics.)

File and Disk Utilities

PageDefrag

Defragment your paging files and Registry hives! (I use this on all of my VPCs. It runs at boot time. I’m not sure whether it’s compatible with SafeBoot, though.)

Junction

Creates Win2K NTFS symbolic links. Think of it like shortcuts within your directory structure.

Networking Utilities

AD Explorer
Active Directory Explorer is an advanced Active Directory (AD) viewer and editor.

Whois
See who owns an Internet address.

Process Utilities

Process Explorer
Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. This uniquely powerful utility will even show you who owns each process.

Process Monitor
Monitor file system, Registry, process, thread and DLL activity in real-time.

Security Utilities

AccessChk, AccessEnum, ShareEnum

Tools for determining who has access to what. Quite handy when configuring security.

SDelete
Securely overwrite your sensitive files and cleanse your free space of previously deleted files using this DoD-compliant secure delete program.

System Information Utilities

PsLoggedOn
Show users logged on to a system. (Use this when you need to TS onto a shared DEV server, but there are already too many sessions.)

Miscellaneous Utilities

BgInfo
This fully-configurable program automatically generates desktop backgrounds that include important information about the system including IP addresses, computer name, network adapters, and more. (We use this on our servers. But, I also use it on my VPCs to remind me which one I’m in.)

BlueScreen
This screen saver not only accurately simulates Blue Screens, but simulated reboots as well (complete with CHKDSK), and works on Windows NT 4, Windows 2000, Windows XP, Server 2003 and Windows 9x. (Geek humor.)

You’re still here? Why aren't you downloading these tools? Go! Download them now!

OOP Book Recommendations

There were two books that really helped me understand object oriented programming and design patterns.

The first was a book called Design Patterns Explained by Alan Shalloway. Alan is a local guy. He runs NetObjectives. And, he’s a frequent speaker on Lean Software Development. His book is eminently more readable than the seminal Gang of Four Design Patterns. (Though, had it existed, when I first started learning patterns, I think that the book Head First Design Patterns by Freeman and Freeman would have helped me learn even quicker.)

The second book is Robert C. Martin’s Agile Software Development. Bob is an institution in object-oriented programming circles. People are so familiar with him that his nickname is “Uncle Bob.” He wrote an article for C++ Programmers Journal for years. This book reads like a collection of those articles. The value I found in his book was that it looked at the principles underneath design patterns. These things help me write better code whether I’m using a formal pattern or not. There’s a good, short article on his blog about these principles that I highly recommend, especially if you don’t have the time to read the book: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod.

.NET Reflector: Your personal X-Ray machine

Have you ever run across a situation where you were trying to debug some code, but you hit a wall when you ran into an object that you don’t own? Happens to me more often than I like. And, before I learned about .NET Reflector, I was stuck using debug.print statements on either side of the object call to figure out what was going on inside.

.NET Reflector changes all that. Need to see the code for an object you don’t own? Crack open any .NET assembly with reflector.exe and disassemble the code. Here the disassembly of a method from a WCF service I wrote recently:

image

You can even use this tool to disassemble objects in the .NET Framework!

Plus, .NET Reflector includes a Visual Studio add-in that lets you debug into this disassembled code! So, no more debug.print. Just follow the flow of execution right on into that code you don’t own. Who knows, you may even find someone else’s bug in the process of solving your own!

iPhone Developers Training Notes

It’s been a couple of weeks now since I attended the Voices That Matter: iPhone Developers Conference. That distance has given me an opportunity to get plugged back in at work – and forget everything I heard at the conference. Fortunately, I took notes.

The conference was hosted by (can you guess?) a book publisher – namely, Pearson Education. As such, they happened to know of a couple of guys who’d just written a book about development on the iPhone OS platform: Aaron Hillegass and Joe Conway of Big Nerd Ranch. Everyone at the class received first editions of the book, which hadn’t even hit the shelves yet.

The class centered around the book, which was clearly drawn from their experiences teaching classes. We’d spend a while listening to lecture, then we’d code for a while. Nothing too complex. But, I learned a whole lot. Here are some of the good bits:

The iPhone OS is a modern, event-driven operating system, not unlike Windows or OS X.

(Oo! Big surprise!)

Basically, the OS sits around waiting for events to happen. An event might be the user swiping their finger across the screen. Or, it might be system generated, like an incoming phone call. In any case, the OS spends most of its time waiting. And, when it’s not waiting, it’s executing “the event loop” which looks like this:

iOS Main Event Loop

Thank Apple for the pretty picture. The Big Nerd Ranch guys had a better, more technical drawing in their slides. Alas, they did not share their slides with us.

Model-View-Controller

Everything about the iPhone OS is based on the Model-View-Controller (MVC) design pattern. There does not appear to be a way to write an iPhone OS application without using that pattern – at least not with XCode, the Apple development environment. (Think Visual Studio for Mac OS X and iPhone OS apps.)

Frankly, I find this incredibly impressive and beautifully elegant. Each application you build consists of one or more Views (screens or sub-screens); a Controller for each and every View; and one or more Model objects for storing data.

Objective-C is weird!

You know those warm and fuzzy things like “dot notation” that C programmers have been accustomed to for decades? Yeah, they changed that in Objective-C. Instead of using periods to call a method on an object, like this:

Object.Method;

Objective-C uses a square bracket notation, like this:

[Object Method];

Furthermore, you know that old familiar way you’ve been sending parameters to methods, comma separated lists inside parenthesis? Yeah, they changed that, too. So, instead of this:

aCircle.draw(point, radius);

In Objective-C, you write this:

[aCircle drawAtPoint:point OfRadius:radius];

In other words, Objective-C forces you to name your parameters. And, they even include them in the method name. The method above is called “drawAtPoint:OfRadius:”. They even pronounce the colons! Too weird!

Note: As a side effect of including the parameters in the name of the method, Objective-C does not support method overloading, since changing the parameters changes the name of the method.

No Garbage Collection

But, not all of the old, time-honored traditions of the C language are gone. No! Memory leaks are as prevalent as ever thanks to the lack of a memory manager with garbage collection.

Actually, OS X (on which the iPhone OS is based) does have garbage collection. Apple chose to remove it due to the memory constraints on the devices (according to Aaron and Joe).

Here’s how it works. When you want to declare a variable, you first allocate memory for it on the heap, and initialize (or zero out) the memory:

myArray = [[NSMutableArray alloc] init];

This line of code calls the static “alloc” method on the NSMutableArray class in order to set aside enough memory for the array, then calls the “init” instance method on the new object to zero out the allocated memory. After the methods run, a pointer to the memory in the heap is placed on the stack in a variable called myArray.

Note: It’s quite common to see methods strung together like this.

Now, if you just allocate more and more memory without ever releasing any of it, you’ve produced a classic memory leak, ala C programs on MS-DOS in 1981. So, the good programmer will clean up after themselves, like this:

[myArray release];

Simple enough. But, easy to forget.

Alternatively, you could flag the variable as to “autorelease” at the end of the current event loop, like this:

myArray = [[[NSMutableArray alloc] init] autorelease];

It’s not quite that simple in reality. But, you get the point. (And, one veteran OS X and iPhone OS developer I spoke to at the conference recommended that until I really understand what I’m doing, I should always autorelease my variables just to be safe.)

Conclusion

I could keep writing for hours. The class was fantastic. I learned an incredible amount. But, I’ll wrap it up here with a couple thoughts about developing on the iPhone OS platform.

First, developing on the iPhone OS is not easy – especially if you haven’t developed on the OS X platform. Therefore, outsourcing a native application will likely be quite expensive – much more so than a typical business application. But, training internal staff would likely take too long, resulting in potential opportunity cost.

Second, the iPhone OS platform offers some particularly attractive features. But, beyond the cool factor and the general mobility of the device, corporations need to think long and hard about why they want an iPhone OS application over an HTML5 application before they invest their money.

ASP.NET MVC for the Rest of Us

If you subscribe to the MSDN Newsletter, you may have already seen this. But, I wanted to let you know about it just in case.

Microsoft has published a series of introductory presentations about ASP.NET MVC entitled “ASP.NET MVC for the Rest of Us”. I just watched the first video (of three). It gave a good overview of the similarities and differences between traditional ASP.NET WebForms and ASP.NET MVC.

If you’re doing web development, I recommend watching the videos. They’re only about 30 minutes each. And, the ground they cover is an important foundation. Even if you’re already doing ASP.NET MVC, you’ll probably gain something from these videos.

Here are the links: Part 1, Part 2, Part 3.  

ReSharper: Don't use Visual Studio without it!

According to IntelliBrains, ReSharper is:

the most intelligent add-in for Visual Studio 2005, 2008 and 2010 that provides a rich set of features to boost individual and team productivity in the world of .NET development.

Ooo! Marketing speak! Allow me to translate:

ReSharper is a Visual Studio add-in that adds over 70 features to the development environment. I linked directly to the feature list on the ReSharper web site, because there are just way too many for me to cover here, and they do a good job of showing you the salient points of each feature. But, I would like to point out a few of my favorite features: (I borrowed the images from the ReSharper web site to save me the time.)

Code Analysis

As I type, ReSharper is analyzing my code, looking for several things:

  • Errors (“that code won’t compile”),
  • Warnings (“that code may cause a null reference exception at runtime”),
  • Suggestions (“the type of that parameter can safely be changed to its parent class”), and
  • Hints (“your code might be easier to read if you invert that if statement”).

ReSharper Hint

This, to me, is the single most valuable feature of ReSharper. I would not code nearly as fast without it.

Navigation & Search

ReSharper offers several “Go To” tools that will significantly speed up your navigation of your code:

  • Go To Type (CTRL+N) takes you to any type in your solution, even by typing just the upper case letters (a feature JetBrains calls “CamelHumps”):

ReSharper Go To Type

  • Go To File (CTRL+SHIFT+N) takes you to any file in your solution – a huge help on huge projects.
  • Go To Symbol (CTRL+SHIFT+ALT+N) takes you to any method or variable in your project.

Refactorings

Here’s a picture of a small subset of the refactoring support in ReSharper:

image

One particularly interesting one in that list is “Use Base Type where Possible…” which is a very good habit. Using abstract classes and interfaces allows you to break coupling in your code. I could write several blog posts about just this one refactoring. Admittedly, though, my use of the refactorings tends toward smaller scale things like “Extract Method” and “Inline Method”.

 

Code Generation

Advocates of the agile practice called Test Driven Development (like myself) have long derided Visual Studio for offering to write unit tests for code that already exists, but not offering the opposite feature – generating method stubs from tests that were written before the code existed. ReSharper fills that gap quite nicely:

ReSharper method generation

If you do TDD in Visual Studio, this feature alone will pay for ReSharper. (And, if you’re not doing TDD, why not?)

Coding Assistance

Here’s a feature I didn’t even know existed until I started writing this article. It’s called “Complete Statement” and it automatically completes the current statement.

When you reach the end of a statement, like this:

ReSharper Complete Statement 1

Simply press CTRL+SHIFT+Enter and ReSharper completes the statement, and places the insertion point exactly where you’d want it, like this:

ReSharper Complete Statement 2

I think I’ll be trying that one out later today.

Code Cleanup

Ever open a file and discover that whoever created it had their tabs set to 2 spaces, making the text too dense and the indentations too shallow for you to quickly grasp the structure of the document? ReSharper can help you there, too. Simply press CTRL+ALT+F to format the file using your preferred format settings.

Code Templates

ReSharper completely replaces the rather limited Visual Studio “Code Snippets” feature with their own Live Templates feature. Here’s an example of their “foreach” template at work:

ReSharper foreach Template

Notice that ReSharper knew which object you were likely to want to iterate over. Very smart. Very useful. To access the feature, press TAB after typing in the name of a live template, in this case “foreach”.

Unit Testing

ReSharper automatically detects NUnit and MSTest-based unit tests in your projects and allows you to run them directly within the Visual Studio user interface. The runner is not perfect – JetBrains doesn’t always quickly add support for new features as they are added to the unit test frameworks. For example, ReSharper 4.5 does not support the NUnit [TestCase] attribute for creating data driven tests. But, I rarely use the [TestCase] attribute when doing TDD tests, which is primarily how I use the unit test runner.

In Conclusion…

If I still haven’t convinced you to take a look at ReSharper, I recommend taking a look at their website before writing it off completely. There are so many useful features that I didn’t cover here, you’re bound to find half a dozen favorites of your own. Heck, even if you’re already using ReSharper, spending some time on their website will likely show you something you don’t know about the product.

FxCop

It has come to my attention that not everyone knows about or uses all of the development tools I know about and use. As such, I’m going to start a series of posts about development tools you should be using, starting with FxCop.

FxCop is a “static analysis” tool from Microsoft. Here’s how they describe it:

FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements.

Here’s what it looks like:

image

FxCop comes with a large suite of rules for evaluating software assemblies. To run it, compile your software, open FxCop, select a target (Project / Add Targets…), select the rules you want to include (Rules tab) and click Analyze (on the toolbar).

What you get is a list of all the places your code violated the selected rules (in the right hand pane) and details for each violation (in the lower pane). As you can see from the size of the position indicator in the scroll bar, running FxCop on the new WCF middleware interface (Symetra.Services.Middleware.dll) produced quite a few errors. (Yikes!) Looks like I’ve got my work cut out for me before I put that code to bed.

Static analysis tools like FxCop are typically run during an automated build process to ensure that all of the developers on a team are following sound development practices. As Microsoft mentioned (above) FxCop is specific to design, localization, performance and security. Another Microsoft tool called StyleCop can alert the team to violations of the team’s coding standards. But, that’s another post.

For now, I hope you found this post handy. Because, to paraphrase Red Green: “If the developers don’t find us architects handsome, they should at least find us handy.”

UPDATE: I thought of a few more things to point out this morning:

  1. Note that the FxCop bits can be found in AccuRev under the Lib\FxCop folder.
  2. I setup the WCF Middleware Service stream to “include” the latest FxCop bits from the stream entitled sym_Lib_FxCop_1.3.6.
  3. I checked-in .FxCop ruleset file in the same folder as the .sln file. I also added it to the solution in a solution folder, so it would be in my face – and I might remember to run FxCop locally before checking in my code.

Lean Software Development

In my previous life, as a developer on the Microsoft Visual Studio Team System Process Team, I helped design workflows for user stories and other types of work items. These workflows were to be integrated into the process as a status field on the work item. At one point, we identified a workflow that boiled down to something like this:

  • New
  • Grooming
  • Groomed
  • Developing
  • Developed
  • Testing
  • Tested
  • Deploying
  • Deployed
  • Accepting
  • Accepted

At the time, we felt that it was important to make a distinction between items that were actively being worked and those that were waiting for the next stage of the process. In the end, we simplified the status field by dropping all the active verbs (those ending in “ing”), in favor of assuming that all work in the current sprint was active.

Part of me likes that decision – it certainly simplified the workflow. But, part of me, to this day, bemoans that decision because it limits a team’s ability to identify waste within the process that needs to be eliminated.

Imagine a process for building widgets. In this process, each widget starts life as raw materials. These materials get flobbled, marned, and volmed before becoming actual widgets. As materials move through the process, sometimes there are too many to marn all of them at once. So, those “in-process” materials sit and wait for their turn at the marner. Similar delays may also happen at the flobbling and volming workstations. And, of course, at any time, one of the machines could break causing downstream process points to run out of work.

This is a typical manufacturing process. And, it’s just like the software process described above.

In Lean manufacturing (a process improvement method invented by Toyota) the time a piece of work has to wait for a machine is considered waste. (It was a waste of money to buy more materials than the process can handle.) Likewise, the time a machine has to sit idle waiting for the next piece of work is also considered waste. (Idle infrastructure is a waste of the investment incurred to obtain and operate said infrastructure.) Lean manufacturing seeks to eliminate all of that waste. Out of this movement have come innovations like just-in-time inventory.

Likewise, in Lean software development, time spent in the inactive states (those verbs ending in “ed”) is considered waste to be eliminated. In other words, why groom 20 stories when the developers can only work on five at a time. The Product Owner may never prioritize some of the other 15 groomed stories high enough for the team to work on them, rendering moot the effort spent grooming those abandoned stories. Likewise, why continue developing code when there are broken tests? Until the tests are fixed, nothing can move forward in the process.

Scrum lends itself to Lean software development through its iterative, incremental approach to building software. So, the team only needs to groom enough work for the next sprint, for example, reducing the potential for time to be spent grooming stories that will end up being abandoned.

The metaphor breaks down a bit, though, when you run into a particularly urgent but poorly understood request from the business. It may take so much time to groom that development stalls, waiting for well understood requirements. This is wasteful in that the developers and testers (the infrastructure of software development) are idled. Extreme Programming’s approach to this situation would be to punt the poorly understood requirement until such a time that it can be adequately articulated. Scrum is less, um, confrontational, but no less dependent upon adequately articulated requirements.

As with everything else on this blog, I just needed to get this out of my head. I hope you found it interesting and/or useful. But, if not, at least my brain can now move on to something else.

The Matrix Reloaded

I wrote this post quite a long time ago – right on the heels of my original test matrix posts. Why I never posted it is beyond me. I’m posting it now to get it out of my “drafts.”

---

A few posts back, I discussed The Marick Test Matrix and my minor modifications to the matrix. In those posts, I described how to classify different types of testing into the four quadrants of the matrix. It turns out that you can also use the same matrix to classify testing tools, like this:

image

Let’s look at each quadrant, in more detail, starting on the right hand side:

Business/Defects

This quadrant represents those types of tests that identify defects in business (or non-technical) terms. In other words, you don’t need to be a programmer to figure out that there is a defect.

Typically, these tests are not automated. So, there are no automation tools to discuss, here.

Technology/Defects

This quadrant represents those types of tests that identify defects in technical terms. In other words, you probably need to be a programmer to figure out that there is a defect. Therefore, one would expect the tools in this quadrant to be highly technical and to require specialized skills. In fact, there are people who specialize in this work. They are typically called testers; but, their knowledge of programming is often greater than the average developer.

The dominant tool in this space is Mercury LoadRunner. Microsoft also has tools in this space, including the Visual Studio Team Test Load Agent and the Microsoft Web Application Stress tool (MS WAS).

Business/Requirements

This quadrant represents those types of tests that define requirements in business terms. As such, you would expect the tools in this category to be (relatively) non-technical. Business Analysts and end users should be able to use these tools to create automated tests without knowledge of computer programming. In fact, these tests should be written by those team members with the most business expertise.

FIT, FitNesse, STiQ, WebTest and Selenium are all examples of tools that allow tests to be expressed in business terms. All of these tools are well suited to use by Business Analysts.

Technology/Requirements

The testing that takes place in this quadrant defines requirement in technical terms. Therefore, you would expect to see lots of low-level, code-based tools, here. These tools are generally used by computer programmers (e.g. developers and testers).

JUnit and NUnit are the big dogs in this space. Other tools include MSTest, WatiN, MBUnit, xUnit, RSpec (for Ruby), and NUnitASP.

Votebox

As much as I love Rally for managing work, I think I may have found something better. Votebox is where Dropbox users can request features and vote for those they’d most like to see. What I like about it is how simple it is:

image

Here you see the three most popular feature requests on their site. Each feature request contains a title, a short description, a category (not shown) and some metadata (in red). Users may vote for and comment on feature requests (in blue). And, Dropbox can update the status of a specific request (in green).

This is the simplest, most elegant site I’ve ever seen for managing a backlog of work. It simultaneously a) houses the backlog, b) tracks feedback, c) gauges interest in competing priorities, d) communicates progress, and e) manages expectations. It’s like a suggestion box that worked out really hard, but never took any steroids. It has all the muscle it needs, without all the bulging veins and other side effects (er, features) of larger sites like Rally.

The only thing I’d be hesitant to do with a tool like this is turn over product decisions to the crowd. What makes Votebox work for Dropbox is that Dropbox has stayed true to their original product vision – a simple, 100% reliable way to backup files to the Internet and sync them across multiple computers. Feature requests outside that vision may be popular, but they would dilute the brand, causing more harm than good to the product.

Rather, I see Votebox as a tool to help talented Product Owners with strong visions for their products interact with their audiences.