Posts
114
Comments
127
Trackbacks
10
November 2010 Entries
Better keyword than "await" - How about "async"?

My late contribution to a debate that was raging almost a month ago now…

Regarding the upcoming C# 5 asynchronous programming improvements, Eric Lippert blogged about how Microsoft is aware that the "async" and "await" keywords, as shown below, imply the opposite of what they really mean:

async void ArchiveDocuments(List<Url> urls)
{
  Task archive = null;
  for (int i = 0; i < urls.Count; ++i)
  {
    var document = await FetchAsync(urls[i]);
    if (archive != null)
      await archive;
    archive = ArchiveAsync(document);
  }
}
 

Regarding "await", Lippert said:

The “await” operator used twice in that method does not mean “this method now blocks the current thread until the asynchronous operation returns”. That would be making the asynchronous operation back into a synchronous operation, which is precisely what we are attempting to avoid. Rather, it means the opposite of that; it means “if the task we are awaiting has not yet completed then sign up the rest of this method as the continuation of that task, and then return to your caller immediately; the task will invoke the continuation when it completes.

It is unfortunate that people’s intuition upon first exposure regarding what the “async” and “await” contextual keywords mean is frequently the opposite of their actual meanings. Many attempts to come up with better keywords failed to find anything better. If you have ideas for a keyword or combination of keywords that is short, snappy, and gets across the correct ideas, I am happy to hear them.

My suggestion (which probably has been suggested by someone else - there was a ton of discussion on this, and it would take days to read all of it): Why not just use "async" instead of "await", e.g.:

var document = async FetchAsync(urls[i]);
 

I don't have a better suggestion for "async" for the method declaration keyword (I don't have a problem with it either). I also don't think it would be confusing to use "async" for both the method and statement keywords. We're "using" the same keyword in different contexts elsewhere in C# without confusion.

My other suggestion: Just make up a new word that doesn't imply any unwanted meaning. "asdf" is easy to type. Smile

Posted On Thursday, November 25, 2010 6:59 AM | Comments (1)
Virtual Brown Bag Recap: Rhino Mocks, Hg-Git
NelsonMocksRhino

At this week's Virtual Brown Bag meeting:

  • Claudio alerted us to his blog post "You Have Been Deleted!", expounding on our DDD/CQRS discussion from a couple of weeks ago
  • Mark talked about / demoed Rhino Mocks
  • George told us about an Hg (Mercurial) / Git syntax comparison cheatsheet, and the Hg-Git plugin
  • Mark hipped us to iconizer.net

For detailed notes, links, and the video recording, go to the VBB wiki page:
https://sites.google.com/site/vbbwiki/main_page/2010-11-18

I'm trying out a new style for the wiki meeting notes pages. The video recordings are now embedded in the wiki, with bookmarks to specific topics in the video, and the notes are in a scrolling div below so you can more easily see the video and the notes together:

image

Posted On Friday, November 19, 2010 5:21 AM | Comments (1)
How to pronounce "IE"

The gentleman below demonstrates the correct pronunciation…

TheBrowserThatWouldntDie

Posted On Saturday, November 13, 2010 9:36 AM | Comments (0)
Virtual Brown Bag Recap: 42goals, Evernote, MVVM, More Cuke

At today's Virtual Brown Bag meeting:

  • Claudio introduced us to goal-tracking site 42goals.com
  • …and shared tips for getting started with Evernote
  • We talked about MVVM 101
  • JB continued his discussion of Cucumber

For detailed notes, links, and the video recording, go to the VBB wiki page:
https://sites.google.com/site/vbbwiki/main_page/2010-11-11

Happy Veteran's Day!

image

Posted On Thursday, November 11, 2010 1:23 PM | Comments (0)
Visual Studio tips for working with whitespace

As George Costanza might say, this is a post about nothing.

…or what looks like nothing, anyway. I’m talking about “whitespace” (spaces, tabs, line feeds, etc.).

I probably spend more time than I should obsessing over the appearance of my code, including whether statements are more readable with or without line breaks.

For example, I might decide that instead of this:

image

…I want to format the statement like this:

image 

(The term “whitespace” is a bit weird with a dark color scheme. You can think of it as “dark matter” for the rest of this post if you prefer.)

In the past, to make the change described above, I would start by positioning the cursor after the opening parenthesis on the first line and pressing the delete key, which would move the second line of code up with the first:

image

Then, I would either select the whitespace between the parenthesis and opening quote mark and hit the delete key, or just position the cursor after the parenthesis and hold down the delete key until, Pac-Man style, I gobbled up all of the unwanted whitespace characters (and usually gobbled up more than I wanted to and had to hit Ctrl-Z a few times to restored accidentally deleted text).

I knew there was probably a keyboard short to do what I wanted, but I was too lazy to look it up. I finally did. the shortcut is:

Edit.DeleteHorizontalWhitespace

CTRL + K, CTRL + \

Collapses white space in the selection, or deletes white space adjacent to the cursor if there is no selection.

In the example above, I would just position the cursor after the parenthesis and press the Ctrl-K,\ “chord” to zap everything between the parenthesis and the opening quote mark.

But wait, there’s an even faster way. If instead of pressing the delete key to bring the second line up to join the first, I had pressed CTRL+DELETE, that would have immediately zapped everything between the parenthesis and the quote mark (including the line feed characters):

Edit.WordDeleteToEnd

CTRL + DELETE

Deletes the word to the right of the insertion point.

If you ever have a need to make whitespace visible (for example, to see if indenting is done with tabs or spaces), you can use the Edit -> Advanced -> View White Space menu (keyboard shortcut: CTRL + R, CTRL + W):

image

Posted On Wednesday, November 10, 2010 1:35 PM | Comments (1)
Virtual Brown Bag: DDD/CQRS
CQRS

At this week's Virtual Brown Bag meeting, Claudio Lassala started out by pointing us to a post on his blog expanding on last week's Liskov Substitution Principle discussion, then talked about two useful tools/sites: CutePDF and ExtensionMethod.net.

The top vote getter on the VBB site's "suggest a topic" page is DDD, so the remainder of the meeting was spent discussing Dorks, Dungeons and Dragons Domain Driven Design.

The DDD discussion quickly turned to the topic of Command Query Responsibility Separation (CQRS). See the VBB wiki page for a ton of links to blogs, podcasts and videos on the subject from brainiacs like Udi Dahan, Greg Young, Chris Tavares and Mark Nijhof.

For detailed notes, links, and the video recording, go to the VBB wiki page
https://sites.google.com/site/vbbwiki/main_page/2010-11-04.
Posted On Saturday, November 6, 2010 9:33 AM | Comments (0)
Tag Cloud