Thursday, August 30, 2007
Debates about the fonts and colors that programmers use tend to get out of control very quickly. While studies on the readability and eye fatigue of various font and color schemes exist, it very much remains a matter of personal preference. However, one detail that many programmers seem to agree on is that the default scheme presented by Visual Studio is less than ideal. Standard 10 point Courier New is simply difficult for most people (at least most people that care about this sort of thing—except Rick Strahl) to look at all day.

VS 2005 Default with ClearType

A common solution—especially for high-resolution displays—is to increase the font size in the editor. Personally, I'm a big fan Microsoft's Consolas font, and as Scott Hanselman points out, I really feel that it looks best at 15 point.

VS 2005 with Consolas and ClearType

This is well-covered territory in the blogosphere, but I want to discuss a point that frequently is overlooked. While many of us strive for the perfect font and color scheme in the text editor, we neglect the opportunities for improvement in other windows. For example, I may feel good about using 15-point Consolas to decrease my eye strain, but I haven't done anything to improve my experience with IntelliSense.

VS 2005 Intellisense

(Public speakers are often the biggest culprits of this. Helpful presenters will increase the size of their editor font, but few will adjust other areas such as IntelliSense, debugging windows, etc.)

Fortunately, Visual Studio 2005 makes changing the fonts and colors of much of the IDE easy. The "Show settings for" combo box on the Fonts and Colors page of Visual Studio's Options dialog provides the ability to customize many areas of the IDE, in addition to the text editor. For example, the default font setting for the statement completion window is definitely too small when compared to the 15-point font size that I use in the text editor.

Statement Completion options

One simple trick to improve the readability of the statement completion window is to use exactly the same font and point size as the text editor. Logically, if I'm searching for a class or method name in IntelliSense, it might be easier to find if it looks exactly like it will when inserted into the text editor.

IntelliSense with Consolas

A similar effect can be achieved by adjusting the font of the editor tooltips. Compare the default setting...

Editor Tooltips

...to the adjusted one.

Editor Tooltips with Consolas

Other good candidates for similar adjustment are:

  • DataTips – These are the cool expandable tooltips that appear when identifiers are moused-over in debug mode. Making these easier to read is a must.
  • [All Text Tool Windows] – This is actually a font and color group that controls several settings. When selected, any adjustment made affects the Command, Disassembly, Find Results, Immediate, Memory, Output and Registers windows.
  • [Watch, Locals, and Autos Tool Windows] – As the name suggests, this group handles adjustments for the Watch, Locals and Autos windows.

Remember: when your goal is to improve readability and reduce eye fatigue, adjusting the font in the text editor isn't enough. Pay attention to the font in all areas of Visual Studio.

posted on Thursday, August 30, 2007 10:15:54 AM (Pacific Standard Time, UTC-08:00)  #    Comments [6]

kick it on DotNetKicks.com
 Wednesday, August 22, 2007
Last night, I had the pleasure of attending Jason Follas' "Exploit the XML Capabilities of SQL Server 2005" talk at the Northwest Ohio .NET Users Group (NWNUG). I have a good understanding of XML and the System.Xml namespace, but I have to admit that I'm a bit of a noob when it comes to SQL Server. It just isn't something that I encounter in my day-to-day work. However, Jason really connected some dots for me. If you have an opportunity to attend this talk, I recommend it.

posted on Wednesday, August 22, 2007 6:02:11 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

kick it on DotNetKicks.com
 Monday, August 20, 2007
..for the Day of .NET is coming.

Day of .NET is a FREE .NET-only conference that is held annually in the Spring. This year's "Nerdo de Mayo" was such a big success that a decision was made to hold the conference bi-annually. Another Day of .NET is scheduled for October 20th in Ann Arbor, Michigan. If you live in Northwest Ohio, Northeast Indiana, Southern Michigan, or Hattiesburg, Mississippi, you should plan on attending. The content is always of the highest quality.

If you are planning on being there, help spread the word in the blogosphere with a delightfully EV-IL badge.

Day of .Net October 20, 2007 - See You there!

posted on Monday, August 20, 2007 6:28:58 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]

kick it on DotNetKicks.com
 Friday, August 17, 2007
Several weeks ago, I posted this bit of code that shows how we might use a C# 3.0 query expression to calculate the sum of the squares of an array of integers.
static void Main()
{
  var numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

  var
sum = (from n in numbers
             where (n % 2) == 0
             select n * n).Sum();

  Console
.WriteLine("Sum: {0}", sum);
}

Translating this sample into Visual Basic 9.0 produces almost identical code.

Sub Main()
  Dim numbers() = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

  Dim
total = (From n In numbers _
               Where (n Mod 2) = 0 _
               Select n * n).Sum()

  Console.WriteLine("Sum: {0}", total)
End Sub

However, this translation is a bit naive because Visual Basic 9.0 actually provides syntax for more of the standard query operators than C# 3.0 does. While we have to call the "Sum" query operator explicitly in C#, Visual Basic allows us to use it directly in the query.

Sub Main()
  Dim numbers() = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

  Dim
total = Aggregate n In numbers _
              Where (n Mod 2) = 0 _
              Select n * n _
              Into Sum()

  Console.WriteLine("Sum: {0}", total)
End Sub

In fact, Visual Basic even allows us to create our own aggregate functions and use them directly in query expressions.

<Extension()> _
Function Product(ByVal source As IEnumerable(Of Integer)) As Integer
  Dim
result = 1
  For Each n In source
    result *= n
  Next
  Return
result
End Function

Sub
Main()
  Dim numbers() = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

  Dim total = Aggregate n In numbers _
              Where (n Mod 2) = 0 _
              Select n _
              Into Product()

  Console.WriteLine("Sum: {0}", total)
End Sub

Here we get the product of the even numbers in the array. (I removed the expression to square each even number because it produced an OverflowException.)

I should point out that there is a behavioral difference that the Visual Basic "Aggregate" keyword introduces. A standard "From" query expression is delay evaluated. That is, the results aren't actually evaluated until they are accessed through, say, a "For Each" loop. However, an "Aggregate" query expression forces the results to be evaluated immediately. In contrast, C# 3.0 query expressions always produce results that are delay evaluated.1

1A bold statement that will be completely recanted if any reader can find an example that proves otherwise.2
2Please, prove me wrong. Seriously. I'm interested in this stuff.3
3This footnote motif is clearly ripped off from Raymond Chen.

posted on Friday, August 17, 2007 7:46:31 AM (Pacific Standard Time, UTC-08:00)  #    Comments [2]

kick it on DotNetKicks.com
 Thursday, August 16, 2007
After writing up this post, I found similar instructions elsewhere. Oh well... you can't always be first.

CopySourceAsHtml on the context menu of Visual Studio's editorCopySourceAsHtml is an extremely useful Visual Studio add-in that places a new menu item on the context menu of the editor. This is especially helpful for bloggers looking for an easy way to get rich source code highlighting into their blogs.

In general, I usually find it necessary to massage the HTML results a bit to get code to look good in RSS feeds, but it is far easier than, say, manual highlighting.

Yesterday, while working on my Art of Currying article, I found it necessary to highlight some C# 3.0 code and was disappointed to find that the trusty "Copy As HTML..." menu item wasn't available. Fortunately, it's very easy to install the add-in into Visual Studio 2008 beta 2.

The CopySourceAsHtml installer drops four files in the "My Documents\Visual Studio 2005\Addins" directory:

  • CopySourceAsHtml.AddIn -- an XML file that describes the add-in and is used for registration with Visual Studio.
  • CopySourceAsHtml.dll -- the add-in itself.
  • CopySourceAsHtml.dll.config -- a configuration file that contains various user settings.
  • CopySourceAsHtml.pdb -- debugging symbols for the add-in. This really isn't needed but it doesn't hurt anything either.

Simply copy these files to the "My Documents\Visual Studio 2008\Addins" directory. If the "Addins" subdirectory doesn't exist, just create it. If you are using Windows Vista, substitute "Users\CURRENTUSER\Documents" for "My Documents".

Next, in a text editor, open the CopySourceAsHtml.AddIn file that you just copied and change the two <Version> tags from 8.0 to 9.0. When you're finished, it should look like this:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<
Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
  <
HostApplication>
    <
Name>Microsoft Visual Studio Macros</Name>
    <Version>9.0</Version>
  </
HostApplication>
  <
HostApplication>
    <
Name>Microsoft Visual Studio</Name>
    <
Version>9.0</Version>
  </
HostApplication>
  <
Addin>
    <
FriendlyName>CopySourceAsHtml</FriendlyName>
    <
Description>Adds support to Microsoft Visual Studio 2005 for copying source code, syntax highlighting, and line numbers as HTML.</Description>
    <
Assembly>CopySourceAsHtml.dll</Assembly>
    <
FullClassName>JTLeigh.Tools.CopySourceAsHtml.Connect</FullClassName>
    <
LoadBehavior>1</LoadBehavior>
    <
CommandPreload>0</CommandPreload>
    <
CommandLineSafe>0</CommandLineSafe>
  </
Addin>
</
Extensibility>

Save the file and... your're done! Start up Visual Studio 2008 beta 2, and that handy context menu item is now available and works great.

posted on Thursday, August 16, 2007 8:03:44 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]

kick it on DotNetKicks.com
 Wednesday, August 15, 2007
It's time to get back to functional programming with C# 2.0. This time, I look at how the technique of "currying" fits into the picture.
posted on Wednesday, August 15, 2007 11:35:46 AM (Pacific Standard Time, UTC-08:00)  #    Comments [7]

kick it on DotNetKicks.com
 Tuesday, August 14, 2007
Warning: GEEK ALERT! The following content may contain language that will fill the reader with an involuntary desire to purchase and read comic books, move into their parents' basement, and wear black T-shirts containing copyright-infringing images or stereotype-perpetrating text, possibly indicating that "Han Shot First." Other side effects may include near-sightedness, uncontrollable acne, and an inability to communicate with the opposite sex. Some readers have also indicated an inexplicable desire to be referred to as "the Dungeon Master." You've been warned...

I recently returned home from Wizard World Chicago. For those of you who are unfamiliar with it, Wizard World is an annual pop culture convention that tours several major cities in the US. The conference entails all manner of geek fetishes such as collectable toys, table-top gaming and anime, but the biggest emphasis is on comic books. Attendance at the conference is usually very high. I'm not certain what the final number of attendees was this year, but last year it was around 58,000. If you compare that with this year's Microsoft Tech Ed attendance of 13,000, you'll quickly realize that Wizard World is truly wall-to-wall geek.

Because there are so many people at Wizard World, my trophy wife and I spent $300 to get two VIP passes. This might seem excessive, but the benefits are pretty sweet:

  • Extra swag. At registration, we received several cool items including 9.8 CGC graded copies of Captain America #25 (the issue where Captain America dies).
  • Early entrance. On Friday and Saturday, VIPs were admitted to the conference floor at 9 a.m., before any other attendees. This allows VIPs to be the first to get conference exclusives and to be at the front of the line to get autographs or sketches from comic creators. Early admittance had another huge benefit that I'll talk about shortly.
  • Exclusive signings. For every scheduled signing by a comic creator there was an additional signing only for VIPs.

Purchasing the VIP passes turned out to be a great investment because they helped us to attend a very important event. On Friday, DC announced that they would be giving out wrist bands early Saturday morning which would provide access to a special panel on Saturday evening presented by DC and Warner Bros. There was a limited number of seats available, and they would be given out on a first-come-first-served basis. As VIPs, this wasn't a problem for us. In fact, our early entrance onto the floor on Saturday ensured that we were among the first to get wrist bands and T-shirts printed with the logo for the next Batman movie, "The Dark Knight." We weren't certain what would happen at this special panel. Currently, "The Dark Knight" is filming in Chicago, so we guessed that there might be a bit of early footage shown. However, when we took our seats later that night with a thousand other geeks, it wasn't clear who might be filling the empty seats at the head table.

Paul Levitz, president of DC, opened the panel with a few words about what was going to happen that evening. After mentioning that there were some surprises for us, he moved quickly to introducing the special guests. Here they are in the order that they were introduced:

  1. David Goyer, screenwriter and comic creator. I'm a big fan of Goyer's work so this was a big "fanboy moment" for me. For the "The Dark Knight," Goyer collaborated with...
  2. Jonah Nolan, screenwriter. Nolan is best-known for his short story "Memento Mori," which is the source material for the excellent film "Memento." After Jonah, Paul introduced...
  3. Gary Oldman, actor. That's right, Gary Frickin' Oldman. At this point, I wet my pants. Next to Oldman sat...
  4. Aaron Eckhart, actor. Eckhart is playing the character of Harvey Dent in the new movie. Next, Batman himself was introduced...
  5. Christian Bale, actor. At this point, my trophy wife wet her pants. Bale got the largest reception of any of the special guests (Oldman was next). He appeared to be quite taken aback by the whole thing. And finally...
  6. Chris Nolan, director. Chris is well-known for such films as "Memento", "The Prestige" and "Batman Begins."

After our initial shock, the panel continued with a Q&A session of which I have no memory. Seriously. It was a completely blur. Fortunately, you can read a transcript here if you're interested.

Next up was the movie footage. They showed us a few minutes of quick scene flashes which were a bit rough since the movie is still filming. There were some exciting shots of Heath Ledger as the Joker getting his butt royally kicked. The footage ended with a big surprise which revealed that Two-Face would make an appearance in the film.

I'm still a bit dazed from the panel (Gary Frickin' Oldman!) but a lot of other great stuff went on at Wizard World. If anyone is interested, I'll post some more stories. However, for the moment, I return you to your regularly scheduled technical blog.

posted on Tuesday, August 14, 2007 6:51:57 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

kick it on DotNetKicks.com
 Wednesday, August 01, 2007
I recently got a comment from a reader thanking me for my blog content (which was nice) and then tweaking me because he couldn't find my name until he started reading the comments. Grrr... What's wrong man? Can't you see it there in the fine print of the copyright text at the very bottom of the sidebar?

OK, maybe that's not so obvious, and I suppose that my readership has grown a little beyond my immediate friends and colleagues. For those of you who are interested, here is the obligatory bio page.

On April 10, 1975, I was born Dustin Russell Campbell in Findlay, Ohio and spent my early years on a steady diet of Star Wars and text adventure games. Fortunately, my father always had a deep interest in computers so there was always some sort of machine around the house. In fact, we owned one of the first TRS-80 Model I machines in the city. MY first computer was a Commodore VIC-20 (eventually graduating to a Commodore 64) on which I became interested in programming (in BASIC of course!). We purcharsed our first PC in 1986-87, and I immediately fell in love.

Junior high and high school were turbulant times for me. In 1987, for the same reasons that most boys do (chicks and dough), I took up guitar. To my mother's shame, I gravitated towards hard rock and heavy metal. I was always that kid in the back of the honors classes with long hair and a Metallica T-shirt. You know the one. (I have pictures, but I'm not showing.) However, it wasn't always black T-shirts and loud guitars. I also played the viola from fourth grade all the way into college. So, even throughout a period of heavy teenage angst, I found enjoyment in many other styles of music (e.g. classical, jazz, etc.).

After high school, I had two choices of career to pursue in college: computer science or music. At the time, music was more attractive (chicks and dough, remember?), so I entered Bowling Green State University in the Fall of 1993 as a Guitar Performance major with a jazz emphasis. That's right dear readers, I went to college for jazz guitar and studied with the masterful Chris Buzzelli. It might surprise some of you to learn that, at BGSU, this is one of the hardest music degrees to get. In fact, out of the 16 guitarists that started with me, I was the only one to earn the degree.

Throughout college, I made ends meet by doing various odd jobs (programming, support, whatever...) for my father's fledgling software firm. He eventually converted me from Visual Basic 6 to Borland Delphi, with which I learned proper object-oriented programming skills.

In August of 1998, I finally graduated with my Bachelor's in Guitar Performance and had no idea what I wanted to do. Programming was certainly a draw, but I wasn't particularly interested in joining the Geek Squad just yet. So, I re-enrolled at BGSU as a graduate student in Guitar Performance. To help pay my way, I took a graduate assistantship as the College of Musical Arts' web developer. I stayed in school for one more year and then dropped out because my interests had shifted. I just didn't have the same passion for music that I had for computers and technology. (It turned out that "chicks and dough" was a myth.)

After dropping out, I stayed on as the web developer and continued programming for my father. It wasn't glorious, but it was fun and I earned a reasonable living.

Eventually, I started using CodeRush for Delphi and developed a friendship with its creator, Mark Miller. In the Spring of 2003, Mark contacted me and asked if I had been working in C# yet. He further elaborated that he was working on a super-secret project and needed me to join him in Las Vegas for a couple of weeks. At this time, I had only been married for a few months, but my trophy wife was gracious and told me to go. When I arrived in Vegas, Mark informed me that Developer Express was aquiring his company and all of his products, including CodeRush. We would be working on the new CodeRush for Visual Studio. I continued on the product as an independent contractor throughout the summer and joined Developer Express as a full-time employee in September of 2003.

Currently, I am the Lead Developer for the IDE Tools division at Developer Express. My responsibilities include much of the low-level plumbing for the DXCore, CodeRush and Refactor! products. I am passionate about becoming a better developer and spend a great deal of my free time learning new technologies. In addition, I enjoy speaking on a variety topics whenever I can get anyone to sit still long enough. For my contributions to the C# community, I was awarded with Microsoft MVP status in April of 2007.

There's more to come—of that I'm certain.

posted on Wednesday, August 01, 2007 7:28:33 AM (Pacific Standard Time, UTC-08:00)  #    Comments [5]

kick it on DotNetKicks.com