If only I were

Building Great Software

Archive for March 2008

Team System 2008 VPC

leave a comment »

If you would like to experiment with the new Team System bits you can just download the vpc here. The bonus here is that there are 38 hands-on labs right in the vpc.

Written by Chris Sutton

March 31, 2008 at 10:49 pm

Posted in Technology

Tagged with , ,

Rubyists, Pythonistas, Perl Mongers, Java and Smalltalk

leave a comment »

If you are geeky and keep up on different programming languages you will likely get a kick out of this video which was shot at Ruby Conf.  Warning, if you aren’t paying attention to current programming language developments this video will likely pass right over your head.

Written by Chris Sutton

March 31, 2008 at 10:16 pm

Posted in Technology

Tagged with

TechEd 2008 – Developers

leave a comment »

This year for the first time TechEd is spanning two weeks. The first week is for developers and the second week is for the “other” people – the IT Pro crowd :)

I’ll be working at TechEd as a Technical Learning Guide(TLG) in the Hands on Labs area and may do an Instructor Led Lab. It’ll take 32 hours of the week, but I’m hoping to catch some of the other sessions as well.

The word on the street is that all of the TLG’s will be wearing sexy black shirts, so it should be pretty easy to find us. 

The conference is in Orlando the first week of June. It might be worth checking it out if you have a week to spare and want to get some insight on the latest technologies from Microsoft.

Written by Chris Sutton

March 31, 2008 at 9:34 pm

Posted in Technology

Tagged with , , , ,

PowerShell Hex to Char

with 4 comments

Rob Conery posted a poem in hex on Friday and since I’m playing with PowerShell quite a bit, I decided to convert it back to readable English with some PowerShell.

First, I copied and pasted the hex characters into a text file and saved it as message.txt.

Next, I needed to load the file into a PowerShell variable so I could manipulate it. I’m issued the command in the same directory where message.txt is located.

$m = gc message.txt

Explanation: PowerShell variables are always prefixed with a $ symbol so in this case $m is going to hold the contents of message.txt.  gc is an alias to the Get-Content cmdlet which literally get the contents of a file.

Next, we build up the actual statement to convert the hex values to decimal and then decimal values to a characters.

$m.Split() | % {[Convert]::ToInt32($_,16)} | %{[Convert]::ToChar($_)}

.Net Type Explanation: $m is a string type at this point. You can verify it by issuing this statement – $m.GetType().FullName – and you will get System.String back. PowerShell is built on top of the .Net type system so you have access to all of the same objects and members as you do in C# or VB.Net.  $m.Split() is going to give back an array of strings.

Pipeline Explanation: You can’t go very far in PowerShell without encountering the pipeline. The statement above you read from left to right, and you use the | symbol to separate the statement into three distinct sections. The first section makes an array of strings from the original data.  The second section converts each hex value to an integer and the third section changes the decimal value to a readable character.  Each section of the pipeline gets processed and then the results of the current section get passed to the section to its right so it can do a new set of operations.

% Explanation: The % symbol is an alias to the ForEach-Object cmdlet. It is also aliased as foreach. % is usually going to be paired with a block {} that will be repeated for each item in a list/collection/array.

$_ Explanation: $_ is a variable reference to the current item in the foreach operation.

[Convert] Explanation: Square brackets around a word like [Convert] say that you are invoking a preexisting .Net type called Convert. If you were writing a C# or VB.Net app you could easily call Convert.ToInt32(“32″) and it would convert the string representation to an integer type.  So here, [Convert].ToInt32($_, 16) is an overload of the ToInt32 function that takes a string representation of a hex value and converts it to an integer.

:: Explanation: The :: operator lets you invoke a method or property on a .Net Type, hence we have [Convert]::ToInt32($_,16)

You have to read this poem vertically at this point, but you can do the work to fix that. I’m almost sure there are probably some ways to simplify this expression as well, so feel free to post comments on improvements you would make. This has become a much longer post than I originally intended, but before I sign off here is what the fully qualified expression would look like:

$m.Split() | ForEach-Object {[Convert]::ToInt32($_,16)} | ForEach-Object {[Convert]::ToChar($_)}

Written by Chris Sutton

March 30, 2008 at 2:36 pm

Posted in Technology

Tagged with , , , ,

ReSharper 4 EAP – 764

leave a comment »

I just downloaded and installed nightly build 764 of ReSharper 4. I usually don’t go this bleeding edge, but I’m feeling a little dangerous.

Most people I’ve read say that these builds are pretty stable by now. I’ll post with an update by the end of the week.

Written by Chris Sutton

March 29, 2008 at 7:44 pm

A well-used string extension method

leave a comment »

James-Newton King posted an interesting extension method called FormatWith() that you can call from any string literal or variable.

There are two useful aspects to this function.  1) You can format a string inline instead of wrapping your string with String.Format():

string Name = “Chris”;

“My name is {0}”.FormatWith(Name);

In my opinion, the less you have to nest items – String.Format(“…{0}”) – the easier it will be to read. Chaining items together could be abused, but over all it is simpler for the reader and writer.

2) It allows for named placeholders like this:

Person aPerson = new Person();

aPerson.FirstName = “Chris”;

aPerson.LastName = “Sutton”;

“My full name is {FirstName} {LastName}”.FormatWith(aPerson);

Check out James’ post to see his implementation, its surprisingly simple.

Much of what C# 3.0 brought us was simplified syntax and the potential for code that is easier to read and write (more fluent). This use of extension methods is more natural and expressive and will certainly make my coding cleaner.

Written by Chris Sutton

March 28, 2008 at 8:58 am

Posted in Technology

Tagged with , , ,

PowerShell left hand rule

leave a comment »

PowerShell uses the “left hand” rule when deciding how to interpret operators. Meaning that the type of the value on the left side of the operator is dominant. Here are some examples:

2+2  (gives 4)

2+”2″  (gives 4)

“2″ + 2  (gives “22″, string data type wins out using + for concatenation)

“2″ + 5  (gives “25″, concatenation again)

To have a little more fun try some multiplication:

3 * 3 (gives 9, ok this is still boring)

4 * “5″  (gives 20, the “5″ becomes an integer)

“3″ * 4 (gives “3333″, that’s more interesting, “3″ means the string data type is the primary type, this acts much like Ruby)

Here is a bit more that might be interesting:

15,30,45 + 3  (gives a new list of 15,30,45,5)

15,30,45 * 3  (gives a new list of 15,30,45,15,30,45,15,30,45)

Kind of cool how this works.  The DOS prompt was stone-age comparatively.

Written by Chris Sutton

March 27, 2008 at 6:31 pm

Posted in Learning, Technology, Thoughts

Tagged with , , ,

Solon Public Library

with one comment

If you live near Solon, Iowa you’ll want to check out the Solon Public Library.  It is a good facility and has plenty of resources. There is a great audio book library that I use frequently for my 1/2 hour commute up to work. There are meeting/study rooms that your group or club can use for meetings.

There are a whole set of computers that you can use on a timed basis if you don’t have one at home. If you have a laptop there is a free wireless connection that you can connect to as well.

For children, there are Storytime and Babygarten programs weekly.

They are also in envisioning phase of building out the facility and services.  It’ll be interesting to see what new things the library will bring to the Solon Community.

Written by Chris Sutton

March 26, 2008 at 11:13 am

PowerShell del

with 2 comments

del is an alias to the Remove-Item cmdlet and you can use it pretty much like you did in a DOS shell. But there are some additions.  It can delete more than just files and directories. It can now delete certificates, registry keys, aliases and more.

One of the nicest features is that you can issue a del command with the -whatif parameter and it won’t run the command, but will tell you what would be deleted if you really did issue the command. So del *.zip -whatif would give you a list of .zip files in your current directory, but wouldn’t actually delete them.

If you haven’t tried PowerShell yet and you work from the command line a lot, you really should check it out.  It is a pretty easy transition from cmd.exe, but there is way more power under the hood if you want to dig deeper.

I’ll likely blog more on PowerShell in the future and will link to many of the resources out on the web to help you learn how to use it.

Written by Chris Sutton

March 26, 2008 at 7:39 am

Posted in Learning, Technology

Tagged with , , ,

Source Control Thoughts

leave a comment »

I was catching up on some ALT.Net reading on the Yahoo Group and came across this gem on a thread talking about people’s favorite version control:

I was informed recently that I may have to contribute to a project that’s using VSS… I immediately thought of this quote about VSS by a MS employee “Visual Source Safe? You’re better off printing out your code, putting it through a shredder, and lighting it on fire.”

Just to be fair, if you have your source stored in Visual Source Safe, that is better than nothing. But you can do much better with little effort.

VSS still doesn’t have atomic commits to the best of my knowledge.  What other kind of database that stores information as critical as your source is allowed to get away with non-atomic commits?

If you have had your source stored in VSS for at least a year and you are the admin, how many times have you had to run the database analyzer? And how many times has it told you that your repository or a block of files have been corrupted?  If your repository has been corrupted at least once, you should have red flags all over the place.

Think of this in terms of your regular databases.  If your SQL Server/Oracle/MySQL databases frequently gave you “your database has been corrupted” messages would you keep using that database?

So once again, you can do better. Here are two good options – there are many more.

I think the easiest sell is using a tool like Subversion.  It is a stable and widely used repository.  There are excellent client and admin tools available for many platforms.  I have used Subversion off and on for the last 4 years and heavily for the last 2 years and have been very pleased with it.  It is stable, reliable, accessible and it is actively being improved and developed.

If you are a larger company in the Microsoft space and you have plenty of money budgeted for your source control strategy you might look at Team Foundation Server. I’m using this on an open source project and have been satisfied with its performance and usability. My only gripe so far is that it does poorly in a disconnected scenario – Subversion really shines here.

Written by Chris Sutton

March 25, 2008 at 8:42 am

Follow

Get every new post delivered to your Inbox.