Tim Murphy's .NET Software Architecture Blog

July 2007 Entries

What If All Scripts Supported WhatIf

In a previous post I described a PowerShell script that I created for renaming image files.  The other day I mistakenly put in an incorrect value for one of the command line parameters.  At that point I realized that maybe my script needed the same capability that many of the PowerShell cmdlets have.  It is a parameter called "whatIf".

whatIf is a parameter that cmdlets with a destructive nature make available in order to allow you to verify that your script will work as you intended before committing any changes.

So I gave my script an optional command line parameter of the same name.  This is then conditionally added to the rename-item command so that I can review how my files will be renamed.  It is a simple change that will hopefully avoid a lot of headaches.

First Impressions of VS2008 Beta 2

I decided to take the time to download the latest beta of Visual Studio.  Below are my impressions from initial usage.  This mainly means I opened the environment and played a little. 

The first thing that you notice is that the IDE looks essentially the same as it did for VS2005.  When you create a new project you will notice that there are now options for WPF, WCF, WF and AJAX projects.  Seeing as I spend most of my time in web applications I figured that would be a good place to start.

It is good to see that I no longer need to worry about downloading a separate install to have a project file created for my web applications.  This was a pet peeve of mine.

The first feature that truly got my attention was the Split button in the designer window.  This allows you to have a design view and a source view of your web page at the same time.  Since I am often flipping back and forth between the two this seems like it will come in pretty handy.

I am still not thrilled that web projects run under the ASP.NET Development Server (File System) instead of IIS by default.  I would prefer that it took fewer clicks.  It leaves me longing for the .NET 1.1 days where it would setup a VirtDir for you automatically.  Of course I had problems with that as well, since I didn't want to put the physical files under InetPub.

Of course there is now a LINQ data source.  This is something that I intend to do some experimentation with in the future.

In all the changes don't rock the world, but they are cool and helpful.  For more information check out Scott Guthrie's post about ASP.NET AJAX in VS2008.

Xiine Who?

I heard about Xiine on .NET Rocks and figured I would see what all the hype is about.  It is a reader for magazines, books and other formatted content built on .NET 3.0 technologies including WPF.  Future releases are also support RSS from what they were saying on the show.

I have to say that the interface is pretty clean.  The one thing that I notice is missing from the current release is discoverability from within the application directly.

The main navigation uses a bread crumb menu, which I find a little odd but usable.  I also found it strange that you only two menu options are either change user or read selection.  I like the off line features to be able to read and search my magazines.  The paging paradigm works well although at first I found myself looking for the scroll bars.

In all it looks like it will be a pretty cool product as it grows.  It is worth keeping an eye on.  For more information Code Magazine has an article that explains more of the features.

Pay It Forward

One of my hobbies is photography (webshots, zooomr) and I was listening to The Digital Photography Show podcast where the guest was Kevin Kubota.  He presents photography seminars and is offering scholarships to his seminars.  The interesting part of the application is that you have to describe what charity work you do.  He said that he figures if he is doing something for you then you should be doing something for your community to show that you are serious.

So how does this relate to architecture and development?  I think that this is something that we should be doing within our development community.  If you think about it at some point in your career there was someone who helped you learn a product or concept.  Pay that learning forward.  Get involved with the people you work with that don't have your experience.  You will find that by teaching your skill improve as well and it improves our industry as a whole.

Cool Celebration And Team Building

We had some fun tonight to celebrate a major release for one of our clients and do a little team building.  Fast, some what violent sports are always fun.

Daugherty Chicago Indoor Racing

Renaming Groups of Files With PowerShell

One of my hobbies is photography.  Naming image files so that they are useful can take a significant amount of time.  Personally I like to name them by subject and by date so that they sequence nicely in Windows Explorer.  I'm sure there are hundreds of application that already have this feature, but being a geek and wanting to lean something new I decided to figure out how to perform the task in PowerShell.

The first thing I needed to figure out was how to select a group of files.  I found that the cmdlet Get-ChildItem works nicely for this.

get-childitem -path "c:\pics\RenFair2007"

This is fine for selecting everything in a directory, but what if I only want a range of files in the direcotry?  This is the point at which the Where-Object cmdlet comes in handy.

get-childitem -path "c:\pics\RenFair2007" | where-object -filterscript {($_.Name -ge 'DSC_20') -and ($_.Name -le 'DSC_31')}

The next step is to loop through the results and rename the files.  This takes two cmdlets, ForEach-Object and Rename-Item.  Here is the final statement.

get-childitem -path "c:\pics\RenFair2007" | where-object -filterscript {($_.Name -ge 'DSC_20') -and ($_.Name -le 'DSC_31')} | foreach-object -process {rename-item -path $_.FullName -newname ($prefix + $idx++ + '.jpg')}

Of course this can be shortened up some by using aliases.

get-childitem -path "c:\pics\RenFair2007" | where -filterscript {($_.Name -ge 'DSC_20') -and ($_.Name -le 'DSC_31')} | foreach -process {ren -path $_.FullName -newname ($prefix + $idx++ + '.jpg')}

You will notice that there are two variables, $prefix and $idx.  These will be input parameters on the command line when this is turned into the script.  This final product is the listing below.

if($Args.Length -lt 5)
write-output 'usage: rename_pics.ps1 <path> <firstFileName> <lastFileName> <prefix> <startIndex>

<path>          = path to directory holding files to be renamed
<firstFileName> = characters at beginning of the first file to be renamed
<lastFileName>  = characters at beginning of the last file to be renamed
<prefix>        = characters to be used as the begnning of the new file names
<startIndex>    = fist number in the sequence portion of the file name

1 - Files to be renamed must be in a sequential group alphabetically. 
2 - The prefex will have an underscore "_" and a sequential index number appended to it'
$idx = $Args[4]
$picpath = $Args[0]
$minname = $Args[1]
$maxname = $Args[2]
$prefix = $Args[3]

get-childitem -path $picpath | where -filterscript {($_.Name -ge $minname) -and ($_.Name -le $maxname)} | foreach -process {ren -path $_.FullName -newname ($prefix + '_' + $idx++ + '.jpg')}

Frustrated Locating Dead Trees

I have been trying to learn PowerShell so I went to a book store with the initials BN to see what I could find.  Call me old fashioned, but I still prefer to have hard copies of books.  While I was there I wanted to look for books on my hobbies of photography and astronomy. 

This particular store only had one PowerShell book in a very small computer section.  It had no astronomy books in its even smaller science section.  I got so frustrated I forgot to look for the photography books.  You would think a book store with two floors of racks would have more variety.

Well what do you do?  Ask for help.  It seems they were too busy setting up for a book reading and no one was in the area.  Needless to say, I will be going to their competitors (which I usually do any way) from now on.

Be A Better Developer

I have seen posts like this floating around and then the other day I listened to Hanselminutes where Scott and Carl discussed the subject.  I figured my enthusiasm has been lacking lately and maybe this would be a good way to bump it up a notch.

I need to find a new way to get Microsoft products to learn on.  One of the clients I used to work for had been paying for my MSDN subscription.  With that gone and my current company being a miser with the developer tools I need to come up with a new plan.

The next thing I am going to work on is blogging more.  If you are going to have something to say you have to be learning.  One thing that helped when I first started blogging was to make a list of things I wanted to blog about and post the list.  I managed to cover about 80% so it served its purpose.

I am also going to get back to working on my certifications.  This isn't because I want the piece of paper, but because it will force me to study the topics.

Lastly I am going to get more involved with the development of the .NET and architecture practices within my company.

Now for the fun part.  I am going to tag some people who may or may not appreciate it: Ahsan Alam, Rolando Avila, Jason Hoekstra.  Have fun with it guys.

A Pragmatic Approach to Software Development

On a recent ARCast Ron interviewed Jeffrey Palermo.  The thing that really impressed me was that he really separated the Agile principles from implementation approaches.  The fact that the goal is working code over comprehensive documentation and that designing by testing is just one way of getting there is a much more rational statement than I often read.

Similarly there is an ARCast.tv clip with Peter Provost where he discusses TDD.  The great thing is he discusses where architecture fits with TDD.  He states that architecture is the over arching view of how things fit together and addresses larger business requirements.  That along with concerns such as scalability and maintainability.  The test driven methods are used more at an individual component level.  This makes more sense to me than the impression that I often get that TDD just evolves the entire system magically.

I'd like to see more open discussions with this sort of bent.  To me there is no silver bullet.  In the end we need to create systems that fit the user's need that developers can understand easily enough to maintain.  I believe Jeffrey's point is that these are the type of principles that we should focus on.