My focus is on making software, coaching Agile/Scrum teams, and being a husband and father--definitely not on blogging--so please do not expect very frequent posts here.

Tuesday, September 4, 2012

UX in the wild: “What do you want from me?”

I was recently looking into opening a CaringBridge web site, since I have a special needs daughter with an undiagnosed genetic syndrome. Trying to sign up, I encountered this page:



As an aside: do they even want men to sign up for this site?  Pink and hearts and lowercasing and round fonts and flowers and puppies and rainbows pervade this site, on this page and other pages.  But I digress.
More importantly, notice the form in the screenshot above. I was somewhat puzzled as to which options to choose. Hmm, myself or someone else. Am I creating an account for someone else, on their behalf, or am I creating an account site to benefit someone else, but it is my site?  All I am prompted with is “who is it for”?  I decided it was for my daughter—it is for her benefit, but not for her personally to use.
That was a pretty easy decision, but then I’m confronted with the first name/last name fields.  Do I type my name or my daughter’s name?  Again, the direction is ambiguous.  I started typing my name, presumably because I’ve done this before on hundreds of web sites. It makes sense to me that I would perhaps type in my daughter’s name in a later step.  However, a few clues told me otherwise—the fields are indented under “someone else”, and the following field is “enter your e-mail”, making me guess that the name fields are not asking “enter your name”.  Also, the submit button (properly left-aligned but improperly indented) is labeled “preview site”, telling me there relaly is no step 2 (despite the 4 numbered circles listed at the top) and it would only make sense to put my daughter’s name on this field.  I entered her name and was able to get the preview of my site.  My guesses were right.
The design of this page forgot Jakob’s Law of the Web User Experience: people spend nearly all of their time on other web sites, not yours.  It was only a small gaffe, and the page contained enough clues for me to figure it out, but how many hundreds of users had the same confusion I did?
Incidentally, we also see that we should serve your target market first (here, moms) but don’t alienate your largest secondary market (dads) in the process.
Hat tip to Kamran Ayub for the “Experience in the wild” idea. Others have done this a lot, but I was just reading a few such posts from his blog.  Thanks, Kamran!

Monday, August 27, 2012

Visual Studio 2012: The new Team Explorer and Pending Changes windows

imageThe old Team Explorer in VS2010 (right) was simple and got the job done without a lot of finesse.  It really was nothing more than several aspects of TFS shoehorned into a tree view, grouped by Team Project.
Totally separately, the old Pending Changes window (below) offered some nice features, such as filtering, conflict resolution, TFS work item association, and undoing changes, as seen below.
(You only use these windows if you use any aspect of TFS; if you are avoiding TFS at any cost, you can skip the rest of this article.)
image_thumb3
imageThe new Team Explorer (right) has several rather major improvements.  Here are the new features that I notice, with a few screenshots so you can visualize these new features.
  • A new Home view summarizes everything important and provides links (rather than tree branches) to each team-related functionality.
    • We now work on one Team Project at a time, changed easily by the select list next to the “Home” title.  This is a great way to avoid wasting screen real estate.
    • Web-style navigation is provided, with Back, forward, home, and refresh buttons. 
    • A feature I love is a project-global work item search, right there on the home view.  So often one or two words (or a work item number) will let me find the task or story I need.  No more do you need to go to the TFS Web Project Portal to search by work item number!
    • The search supports several special terms—helpers for which are in the drop-down. For example, T:"Task" will limit your search to tasks only.
    • A link to Pending Changes are shown with a link to the Source Control Explorer.  No more drilling-down to browse Source Control—it’s right there on the home page!
    • Work Items, Builds, Documents, and Settings work much like in VS2010
    • There is a link to the Web Access (TFS Web Project Portal) right on the home screen.
  • The Pending Changes section (below) is all new and built-in in the Team Explorer, totally replacing the old Pending Changes window.
    • Again, you can change team projects right next to the “Pending Changes” title.
    • A workspace select box is immediately below that.
    • The Check In, Comment, and Shelve controls are easily available. 
    • Lesser-used actions (find shelvesets, resolve conflicts, undo all, manage workspaces) are hidden in the “Actions” select control.
    • We have two separate sections of included vs. excluded changes.  This is a much better paradigm than having to fiddle with checkboxes in one big list.  Simple text controls are provided to manipulate these lists.
    • A simplified way of adding related work items is here; the default direction is to simply drag the work items in to a drop target.  This makes a lot of sense to me, as I have to look up the item anyway, and I probably have it open in a different window.  If you prefer to do it in this window, you can—either by looking it up or by typing in an ID.
    • Finally, specify reviewers in the notes if you are using the TFS reviewing system.  If not, just collapse this section and ignore it.
image
  • The Work Items section (below) is not substantially different than in Visual Studio 2010.  A few differences:
    • There is a “My Favorites” drop target for you; queries dropped here will give you a summary of the work items in that query.
    • A handy “New Work Item” control at the top seems useful.
image
New in the Builds section (below):
  • The most recent builds with their red/yellow/green status
  • A drop target for My Favorite Build Defintions, also with a summary
  • A quick filter/search box.
image
All in all, these are some very nice and unexpected feature enhancements here in the Team Explorer window.  I hope they make you more productive!

Tuesday, August 21, 2012

Visual Studio 2012: The Test Explorer

I’ll be blogging just a little bit about some of the new features of Visual Studio 2012 that I notice as I use it.

Take a look at the new Test Explorer window.

image

This is a much simpler, robust interface than was available in Visual Studio 2010. By default, it provides you with groupings of tests by disposition (failed, skipped, passed, not run).  Rather than having to open up a new window to investigate the cause of a failing test, the same info is shown on the right.  Other nice touches include:

  • A progress bar that turns red when something fails
  • A compact display of elapsed time for each test
  • Run all tests with one click when no tests have been yet run
  • Run failed tests, skipped tests, or any of several common groupings from the toolbar
  • The ability to right click and run a single test, multiple selected tests, or a group of tests
  • Toggle “Run tests after build” so that the tests will run automatically
  • Filter tests by a search term
  • Tests run faster than in VS2010
  • Previous test run’s results remain as greyed-out while the current test run is running
  • Group test results by duration (really handy for focusing on improving the slowest tests)
  • A red-yellow-green summary of all tests
  • No more “Exceptions has been thrown by the target of an invocation” errors (I hope!)

These features are all new since VS2010.  This new window will totally replace both the former Test Results and Test Runs windows for me.  I’d expect this window to be open early and often throughout the development experience.  The test Explorer is docked left by default, but I’ve moved mine to the bottom as seen in the screenshot below.  Enjoy!

image

Monday, April 11, 2011

How can I write WPF efficiently?

When I first learned about Microsoft's then-new framework for developing desktop applications, WPF, I thought that one of the biggest benefits of it would be its efficiency.  After all, I already know what the GUI controls and elements were that I wanted to use--I just have to slap them all on the page and then wire up all my bindings right, and I'll be done.  After that, I learned about the MVVM pattern, which promised clean separation of concerns within my WPF app.

I thought this was going to be great!  I got into creating several different admin and data entry WPF apps with my team at work, and thus I began to crank out working software with robust but simple GUIs, right?

Not so fast, there, cowboy coder. My experience is that writing WPF is S-L-O-W.  

Well, at least the way I do it.  You see, after I have a picture of my GUI on a whiteboard, I code up the XAML with the controls that I want.  This part, as expected, is fast--laying out the whole of a window is pretty quick. After that, its all the little stuff you want these elements to do takes awhile. I always seem to want to make this text bold in some cases; show a red error box in these other cases.

Then things unravel: this binding isn't working right over here--I have to write a converter and adjust the layout for the right values. Whoops, I forgot that extra NotifyPropertyChanged there. Oh, and I want to use a different template in this state vs. that, so I have to figure out what I can use to swap the templates in certain situation.  This data is coming in asynchronously, so I need to make sure the right thing is happening on the right thread and that Property gets NotifyChanged as well.  Crap, when I maximize my window, it doesn't stretch like I thought it would--must be because its container height isn't defined, but I don't want to define that, so I have to make it stretch in its parent.  Oh, now I really want to make a user control out of this stuff over here, so I better implement some dependency properties...

On and on I go, spending hours and days on stuff that just feels so small and minor. I soon resort to cutting usability features and look-and-feel enhancements because this is taking just too darn long.

Does anyone have any tips or principles I need to try in order to write WPF efficiently?  I'm off to search the tubes for some thoughts.

Edit: added link for StackOverflow question.

Friday, October 15, 2010

UML in OneNote

I've started using Microsoft OneNote for note-taking and brainstorming.  Anyone know of a way to compose UML in OneNote?  How about other software architecture diagrams? I suppose I could paste from Visio or perhaps even Visual Studio.

Saturday, September 25, 2010

The ongoing struggle for high-quality unit tests

My team at work has been struggling lately with how ambitious we should be with unit tests. Everyone agrees that we need automated unit tests, and we need to separate them from automated integration tests and run them often. However, I must ask:

How robust should our unit tests be?

There are definitely a few different ways to think about unit testing.  At one extreme is full-on test-driven design (TDD), where every unit of one's software is designed via the unit tests; the unit is responsible for passing all the tests and nothing more. I've never done an actual project using TDD, and I'd like to try--but most teams don't go this far.  The other extreme is to avoid unit tests entirely--everything is tested using integration tests or perhaps manual testing only.  This is not likely good enough for a project of any complexity.

Seems to me that nearly all development projects fall somewhere in between, and my current project is no exception. So we struggle with how robust to make the tests--what functionality needs tests? Is there non-trivial functionality where one might decide to forgo testing in order to work on higher priority things? 

First serious attempt: a "do it right" policy for unit tests

We knew we weren't going to do full TDD. After we realized we needed a better testing policy, we made some rules and guidelines that go something like this:
  • Every non-trivial public member of a class or module must have robust unit tests written for it.
  • Test every possibly different edge case you can think of.
  • Refactor classes so that all dependencies are fully injectible, so that mocked instances can be injected for true unit testing.
    • Use a mocking framework like Moq or Microsoft Moles and Stubs to create more fully-featured mock objects with less refactoring.
  • Submit every test for code review by at least two other developers (we use CodeCollaborator).
    • Reviewers should submit test cases they think are lacking
    • Author should follow-up with new tests
  • Consider using Pex to help you write tests with better coverage.

Writing high-quality unit tests is difficult, tedious, and unenjoyable

To write unit tests well is to spend a lot of time thinking of what all the possible kinds of inputs are--thinking that developers are more interested in investing in their actual implementation. The tools involved (we used MSTest, Moq, Pex, and Microsoft Moles) all have a learning curve and are not what most developers want to learn.

But it's worth it, we all say, so we soldier on and do our best. Say I've implemented a new feature, and I begin writing unit tests for my new classes.  I stub out each test for a class. By the time I finish a few properties, I have stubbed out and provided focused, detailed thought on each of them. My brain is tired because this thought process is tedious and not the kind of problem-solving thought that makes me engaged and interested. If software design and implementation is akin to doing a jigsaw puzzle, then writing unit tests for that software is akin to doing one's taxes.

I now have much of the work done for these tests I've written, and my software will be better as a result.  Maybe I've even exposed some defects or missing features just by thinking about these tests. Now I am fatigued, but it's worth it, right? But hold on; I'm only done with about a third of the testable members of this class. After I write tests for the remaining two-thirds members, I have to continue on and write tests for several other classes that I've added.

But it's worth it, right? Hold on, I haven't considered the classes that I've added to.  I have to open their existing tests and understand all of the tests that possibly relate to my new feature.  I now have to write a few new unit tests for what I've added to that class. So I repeat the process all over again.  Hopefully, this doesn't take as long, since I only have a few changes.

But it's worth it, right? Now my new feature is unit-tested, and for all time into the future, we will have good assurance that each class works well.  Not so fast--I haven't yet modified the tests for changes to existing behavior to support the new feature. Now I have to examine the existing tests so I can change their preconditions, actions, and/or assertions.  I also have to consider if the test is revealing that my behavior change breaks any existing features.  Maybe my change to existing behavior is naive and we need to reconsider it. 

But it's worth it, right?  Suppose now I am done writing unit tests--what a relief!  But now I need to write integration tests, which feels like starting over for much of the same thing.  And I need to consider if any new backwards-compatibility tests are needed for units that work with older software that can't be upgraded at the same time.


I put my tests through a code review, and the reviewers recommended a few additional cases.  Fortunately, it is usually pretty easy to implement tests for these cases after someone else points them out.

The outcome of this is great, but still has a big flaw: to properly execute the above, it takes a lot of time and determination to get it right. We had tasks that were previously estimated at 4 hours (including perhaps an hour to write tests) and being done in a day now taking perhaps 12 mythical man-hours to be done over more than a week.  Do we have better assurance that our software works well and according to our intent? Without question. But how much? Is it worth taking perhaps double or triple the time to develop something?  We've been developing the "old way" for several months, and our impression was that the business was tentatively happy with our results, including the need for support and patching that arose from a few defects.

After a few months of this style, we begin to degrade. It feels like it is taking too much time to write tests in this way; the business seems more and more unhappy with our decreased velocity (and increased estimates). Team morale is down and excitement for the future wanes.

The perfect is the enemy of the good: tweaking the approach

We are keeping the guidelines, but we will now try be wiser in writing tests--we pick and choose which tests to write, which tests to stub out but leave for writing later, and which units to avoid thinking of tests for at all.  We try to always be "better" (writing more, higher quality, and better covering tests) than we were before, yet we try not to go all-out to do it "right" in every possible way.

So my next emphasis is for all the team members to write robust tests when it is beneficial, and to avoid doing work writing robust tests where they won't be beneficial. I plan to "err on the side of writing more tests", since it is sometimes difficult to know which tests are actually unnecessary--but it seems to me that one lesson from this is that we simply don't have the resources to write "complete" or "really good" unit tests as a hard-and-fast rule.

Relaxing our unit-test vigilance might create some technical debt

I fully acknowledge that there is a potential for issues here. My biggest concern with this approach is that it demands individual judgment by each team member on "how good" to make one's testing.  Code review should mitigate this somewhat, but with an amorphous guideline to avoid writing unit tests that aren't beneficial, no one will know exactly how good "good enough" is.  There is a big risk that as a team we will neglect to write beneficial unit tests for a class because no one who read that code thought writing unit tests were necessary or thought they should speak up.

Another good point is that if we don't spend the time to write unit tests now, or we will spend time troubleshooting later.  This is obviously true to an extent; the sooner you find a bug, the fewer resources it takes to fix or otherwise overcome it.  However, I cannot accept that 100% of the unit tests that one could possibly write will result in an error that we have to find later.  The hope is that we can avoid taking time to write the trivial and "almost trivial" unit tests.  The business has already demonstrated that we are somewhat error-tolerant, as long as we can fix errors reasonably quickly; can we be okay with that as well?

I admit that I am long way from figuring out a "sweet spot" approach to this difficult issue.  How does one discern trivial functionality that needs no testing from non-trivial? How can we ensure that needed unit tests exist? Is there a better, more objective goal that we can aim for in our tests?

If we aim to make our unit tests not "really good" but instead "good enough" given the business demands and resource constraints, will they ever be really good enough?  I'd love to hear all your thoughts and recommended articles; please leave your comments.

Monday, September 13, 2010

Hello again, world!

Welcome to the redesigned Szalapski.com!  I've decided to use this domain for a blog on software development and architecture, with a focus on .NET.  Expect sporadic updates for awhile. I've added my Twitter and StackOverflow feeds to this page as well, so you can glance at what I've said recently even if there are no recent posts.

If you don't care at all about software, feel free to follow my other sites: ShareYourFaith.org Evangelism, my Facebook, my LinkedIn or the aforementioned Twitter page.  I'll keep the politics, sports, and faith comments off of this part (the blog), except as occasional "check out this other post" notes for other sites. 
I wouldn't expect updates too often; but, if you want more, leave comments to encourage me.  Hope this site is helpful!