Category Archives: Recommended

FlexBox jQuery Plugin

FlexBox is a jQuery plugin that is intended to be a very flexible replacement for HTML textboxes and dropdowns using AJAX to retrieve and bind JSON data. 

Okay. Now what is FlexBox exactly?

It is a dynamic control which can present itself as a combobox with per-result HTML templates, a suggest box (like Google search) or a data-driven type-ahead input box.  It supports theming/skinning via CSS, flexible paging, configurable client-side cache and much more

Great.  We got it.  It’s clearly flexible, but is it easy to use? 

Yes.  It’s also super easy to use.  image

Prove it!

Okay, for example, you can generate a Google Suggests-type textbox in just a few steps:

  1. Reference jQuery and the FlexBox scripts.
  2. Add an empty div to the <body> tag wherever you want the FlexBox to appear.
  3. And assuming results.aspx returns JSON data and your div has an id = “ffb3”, this code will render a suggest box similar to that represented in the image to the right:
    $('#ffb3').flexbox('results.aspx', {
        showArrow: false
    });

Pretty slick, eh?  FlexBox was developed by a co-worker of mine, Noah Heldman, as an open source project hosted on CodePlex. It is well documented (including a Getting Started Guide) and comes along with a great demo page.  I think Noah did a really nice job with this plugin.  If you’re looking for a searchable textbox/dropdown, I suggest you check it out.

FlexBox CodePlex Project Page
FlexBox jQuery Plugin Page
FlexBox Overview

Required Reading for JavaScript Devs

I read a bit of “jQuery in Action” a couple of weeks back.  Actually all I read was the appendix which is aptly titled “JavaScript that you nejQuery in Actioned to know but might not!”  This short chapter very concisely covers JavaScript concepts which should be required learning for all web developers

If you are an experienced JavaScript developer (i.e. your JS code does more than trigger alerts, toggle divs and set window locations), you know the language is not particularly easy to get your head around.  In my opinion, most web developers have a poor understanding of JavaScript to the extent that the bulk of their JS code (mine included) is a mere collection of hacked-together, simple statements.  Based on my judgement, the appendix title should read “JavaScript that you need to know but you more than likely do not!” 

Generously, “jQuery in Action” provides a thorough overview of “basic” JS concepts like objects and JSON, functions being first-class objects, controlling what “this” means along with closures.  I’ve really enjoyed jQuery in Action thus far – particularly because the authors ensure that their readers have a firm understanding of core JavaScript concepts which are arguably the necessary foundation to effectively use jQuery.

The next time you find yourself in your local bookstore, sit down in the aisle with a copy of “jQuery in Action” and give the appendix a good read.  It’s 19 pages of pure Javascript goodness.  And who knows?  You might even purchased the copy and read the jQuery parts…

 

The Thirsty Developer Podcast

I’ve recommended .NET podcasts before and it’s time to add a new show to the mix.  This past weekend, I started consuming the backlog of The Thirsty Developer podcast in large quantities and I like it.  I found the majority of the shows to be well-structured, high production quality, informative and entertaining.  But I’ll let you be the judge. 

The show is hosted by MS Developer Evangelist, Dave Bost, and MS Architect Evangelist, Larry Clarkin, but don’t let those Blue Badges scare you away as conversations/interviews aren’t solely Microsoft-centric.  Topics vary but generally stay within the interests of the typical .NET developer.  Case in point, my two favorite episodes, thus far, are related to SCRUM.  If you are at all interested in this methodology process, you should give them a listen: 

Again, I find the podcast informative and entertaining. I bet if you like Deep Fried Bytes, you’ll like The Thirsty Developer as well.

Let me know what you think.

.NET Podcast Recommendations

Last Friday, a fellow coder asked the team for podcast recommendations.  Since I listen to anywhere from 6-10 podcasts a week, I was happy to share what is currently in my top podcast rotation. 

It is worth noting that those of us in the .NET community are rather fortunate as there are a number of recent newcomers in this space.  In fact, four of my top six podcasts have been around for less than 4 months.  I personally think they’ve all done a standup job and it has been enjoyable listening to the podcasts as they mature.  Maybe some day, years from now, young developers will gather around as I tell tales of the very first Herding Code podcast. You never know…

Enough with the intro already.  Here’s my .NET Podcast Recommendation List in no particular order (other than alphabetical):

Alt.NET Podcast
http://altnetpodcast.com/
Hosted by Mike Moore
Currently on Episode 8 

Deep Fried Bytes
http://deepfriedbytes.com/
Hosted by Keith Elder and Chris Woodruff
Currently on Episode 8

Hanselminutes 
http://www.hanselminutes.com/
Hosted by Scott Hanselman
Currently on Show #124 

Herding Code
http://herdingcode.com/
Hosted by Jon Galloway, K. Scott Allen, Kevin Dente and Scott Koon
Currently on Episode 11

.NET Rocks!
http://www.dotnetrocks.com/
Hosted by Carl Franklin and Richard Campbell
Currently on Show #365

Stackoverflow
http://blog.stackoverflow.com/
Hosted by Jeff Atwood and Joel Spolsky
Currently on Podcast #16

Getting Started with Inno Setup

For the first time in years, I needed to distribute my application to the end user’s machine via an online download.  To do this effectively and professionally, I, of course, needed an install package.  Over the year, I have used both Wise and InstallShield but they both cost money and I don’t recall them being all that easy to manage.  This was, however, years ago.  More recently I have, like many developers, used Windows Installer to imagegenerate MSIs for very simple (read: file copy) deployments. There’s nothing flexible or particularly pleasing about MSIs, but one can typically get them created with a few button clicks.  For the installation of internal applications, MSIs are more than tolerable, in my opinion.  Other than those options, I was quite ignorant on the subject of installers so I briefly evaluated three free candidates:

  • Windows Installer XML (WiX) Toolset is a Microsoft open source project used to create the Office 2007 installer. WiX includes some advanced capabilities, but it has a steep learning curve even though the scripting language is XML-based.
  • NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for Internet distribution. It has a rich feature list, a good set of online samples and a good community following.
  • Inno Setup is another free, open source installer for Windows programs. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.

Decision

After a quick review of each product, I opted to run with Inno Setup primarily because it had the ugliest website, all of their product award links are broken and it isn’t known by any acronym…yet.  Joking aside, I chose Jordan Russell’s Inno Setup because it met all of my requirements almost effortlessly.  Here’s the rundown of what I needed:

  • Check for the .NET Framework and install if not found
  • Check if Remote Registry is running and start if stopped.
  • Check is UAC is enabled and provide user dialogue.
  • Open website(s).
  • Create quick launch, desktop, start icons.
  • Read, update registry.
  • Ask custom questions and manage response.
  • Launch applications.
  • Install silently.
  • Create associated uninstaller.
  • Show/acknowledge terms of service.
  • Display readme.
  • Customizable/skinnable display.  
  • Etc

Additionally, Inno Setup it is such an easy tool to use and test and it has been around for a long while and has a great feature list:

  • Support for all versions of Windows in use today: Vista, XP, 2008, 2003, 2000, Me, 98, 95, and NT 4.0. (No service packs are required.)
  • Extensive support for installation of 64-bit applications on the 64-bit editions of Windows. Both the x64 and Itanium architectures are supported. (On the Itanium architecture, Service Pack 1 or later is required on Windows Server 2003 to install in 64-bit mode.)
  • Supports creation of a single EXE to install your program for easy online distribution. Disk spanning is also supported.
  • Standard Windows 2000/XP-style wizard interface.
  • Customizable setup types, e.g. Full, Minimal, Custom.
  • Complete uninstall capabilities.
  • Installation of files:
    Includes integrated support for “deflate”, bzip2, and 7-Zip LZMA file compression. The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX’s and type libraries, and install fonts.
  • Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
  • Creation of registry and .INI entries.
  • Integrated Pascal scripting engine.
  • Support for multilingual installs.
  • Support for passworded and encrypted installs.
  • Silent install and uninstall.
  • Full source code is available (Borland Delphi 2.0-5.0).

Oh, and have I mentioned that it is free? 

Getting Started

The basic installer includes the Inno Setup Compiler, documentation and numerous samples.  If you want to get started quickly just download Inno Setup and review the sample scripts.  You’ll be creating your own installers in no time.  Alternatively, you could download/install the QuickStart Pack, but I honestly do not think it is necessary.image

As I mentioned, a review/compilation of the samples can provide a quick, easy introduction into the impressive tool. All the examples are worth a look, but I feel it is necessary to give a few special mention:

  • Example1.iss, Example2.iss and Example3.iss provide a great foundation as they demonstrate how to access the registry, add a desktop icon, include a readme file, etc, etc, etc.  
  • If you are planning to do anything non-standard, play around with the CodeExample1.iss sample.  It essentially builds a basic setup, captures every installer event, includes custom functions, and demonstrates how to extract/expand files, display dialogues and issue before and after installer actions. 
  • Finally, if you want to build custom pages, check out CodeDlg.iss which demonstrates how to build installer pages with custom questions and user input options.

My suggestion is to review the samples from within the Compiler.  The Compiler doesn’t have intellisense or anything, but it will obviously validate your script and call out where imageinvalid syntax exists.  The Compiler also allows you to immediately “run” your installer script (by clicking on the green arrow button) or compile the script (by clicking on the fourth button from the left.) What the heck is that anyway?  The Compile IDE is a fancy notepad with options and actions.  It’s simple and I dig it.

Speaking of simple, here’s an example script.  You would have to build on its foundation if you wanted to do anything fancy, like read from the registry, but these few lines practically do it all.  They copy three files into the Program Files sub directory, displays a read me file and add an icon to the Start Menu.  And all the standard installer pages (splash, location, completion, etc) comes along for free — free meaning no effort and no code.

[Setup] AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files] Source: “MyProg.exe”; DestDir: “{app}”
Source: “MyProg.chm”; DestDir: “{app}”
Source: “Readme.txt”; DestDir: “{app}”; Flags: isreadme

[Icons] Name: “{group}\My Program”; Filename: “{app}\MyProg.exe”

Extra Help

Finding the right syntax wasn’t always a breeze as everything isn’t covered in the samples.  With that said, the best online reference I found was an Inno Setup Manual hosted at AgentSoft.com. I can’t say I know the connection between AgentSoft and Inno but I’m still very happy to have found the reference.  I also found various “real world” installer scripts, like this one, posted online which really helped facilitate my ramp up.

.NET Framework Install Script

In my requirements list, I called out the need to check for the .NET Framework and install if it wasn’t found.  This functionality is a snap using Inno Setup — just be sure to use the Client Profile version of the installer.

[Files] Source: “Executables\dotnetfx35setup.exe”; DestDir: “{tmp}”; Flags: deleteafterinstall

[Run] Filename: {tmp}\dotnetfx35setup.exe; Parameters: “/Q /NORESTART”; Check: Is35FrameworkInstalled; Flags: runhidden shellexec waituntilterminated; StatusMsg: “This may forever.”

[Code] function Is35FrameworkInstalled():Boolean;
begin
    Result := not RegKeyExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5’);
end;

Summary

I’ll keep it short and sweet: Inno Setup is one slick piece of software that made the dreaded task of creating a custom installer one heck of a lot easier than it could have been.  I’ve added Inno Setup to my toolbox and I highly suggest you do too.

Getting Started with AnkhSVN

I’ve previously written about managing your Subversion repositories via the TortoiseSVN client.  TortoiseSVN integrates with Windows Explorer and provides a really slick way to do things like view the status of your source code, update your Subversion working copy and commit change.

But as slick as it is, TortoiseSVN requires one to bounce between their IDE and the Windows Explorer.  You’re right!  A simple, two-second step, a mere ALT-TAB, shouldn’t be that disruptive but, for me, it is and it keeps me from committing my changes as often as I probably should.  Perhaps this is a flaw in the way I work, but it is, without a doubt, the way I work.

There are two players in the “Subversion Source Control Provider for Visual Studio” space.  There’s VisualSVN and there’s AnkhSVN.   Until this week, I had heard nothing but good things about VisualSVN and AnkhSVN reviews weren’t nearly as favorable. 

I ended up trying VisualSVN for over a week and, frankly, I was disappointed. I deserve to get negative feedback about publishing the following comments without any supporting documentation but I found VisualSVN to be sluggish and I felt it called up TortoiseSVN dialogues (rather than handling the file management itself) far too often.  Since so many folks like the product, I would be willing to bet I simply had a very bad first go (although I did spend over 1 week with the product.) All the same, it is uninstalled, the $49 are still burning a hole in my pocket and, well, there was no harm done. 

I reverted to my old ways of not using source control effectively by avoiding Windows Explorer and TortoiseSVN and then, on my birthday, AnkhSVN 2.0 Final was released.  Though folks grumbled about the previous version, 2.0 is a near rewrite of the original and is now a full Source Control Provider Integration Package rather than a Visual Studio Add-In. With commercial backing from CollabNet and renewed open source enthusiasm, AnkhSVN 2.0 seemed to deserve a look so I looked…

Quick Start

1. Download AnkhSVN 2.0 here and run the install package.  If you want the latest and greatest, check out the daily builds

 

2. The AnkhSVN download page says to install and then “Start Visual Studio and choose Tools -> Settings -> Source Control and make sure AnkhSVN is the active source control provider.”  Actually, you want Tools -> Options rather than Settings, but you would probably figure that out on your own.  All the same, AnkhSVN was already configured/selected.

 

3. Open an existing solution and noticed the new “Pending Changes” windows (also available via View -> Show Pending Changes.)  Enter your repository URL into the empty “Working on:” field and, if you are as lucky as me (after all it was my birthday), everything should just work. 

image 

 

4. This step is optional, but inevitable. I think. After about 20 minutes of playing with AnkhSVN you’re probably going to want to hook up your favorite diff tool.  If your favorite diff tool is WinMerge, perform the following: Go to Tools -> Options -> Source Control -> Subversion -> External Diff Path = “C:\Program Files\WinMerge\WinMergeU.exe” “%base” “%mine”

image 

 

5. Once you are setup, you will see green check-marks alongside items in the Solution Explorer window.  And, as you start to make changes, you will see modified items added to the Pending Changes window.  This, my friends, is  a great feature!  Now you able to manage all of your changes in a single location rather than having to navigate through Windows Explorer or even the Solution Explorer. In another life, StarTeam provided me with similar functionality by allowing me to flatten out the folder hierarchy and then sorting by status, but the Pending Changes windows is 100 times better.  Sure, you can manage your commits via the Solution Explorer, but I’m not going to. The Pending Changes view is also great since the Solution Explorer doesn’t always conveniently show you the status of your files.  Take the screen shot below, for example.  Collapsing the EmailTemplates folder leaves me no insight into the state of the files within.  (For the record, I prefer VisualSVN’s Solution Explorer display.)

 

image

 

     

     

     

    Side note: If I could do it all over again, I really wish I followed the posted download instructions.  The suggested setup sounds straight forward enough, but trying to replicate the steps now, after already setting up, is seemingly impossible.  The instructions can be firmed up for clarity (see prior example referring to incorrect menu names), but I would have liked to give them a test run without jumping the gun and setting up my own way first.  If you do follow the published install instructions, let me know how it goes for you as I simply can not make heads or tails out of some of the steps.  One thing which seems to be missing — perhaps because of my impatience — is the persistence of the Subversion repositories added to the Repository Explorer.  It is really nice a version of the Repository Browser is built in, but it seems odd that repositories would need to be reestablished each time you open a solution.  Anyhow, it is probably my fault…

    Wrap Up

    Thus far, I am pleased with AnkhSVN.  For those of you who tried out earlier versions and were disappointed, try again.  Here’s a partial list of what’s new in AnkhSVN 2.0:

    • For Microsoft Visual Studio 2005 and 2008.
    • Built on Subversion 1.5.0 via SharpSvn.
    • Pending changes window; subversion status and commands available in one place
    • Full support for Visual Studio 2005 and 2008; AnkhSVN is now a SCC package instead of just an addin
    • Better log viewer
    • Merge support
    • Property editor
    • AnkhSVN now supports most project types previously unsupported via the SCC api
    • All solution explorer actions (rename, copy&paste, drag&drop) keep subversion history now
    • Enhanced build process and setup
    • Automatic check for updates
    • And last but certainly not least end user documentation

    For more information about AnkhSVN, check out the project’s home.

    ReSharper 4.0 Beta Makes Me Giggle

    Today I did what I should have done a lot while ago.  I watched the Jedi Coding Demo and installed JetBrain’s ReSharper – The Most Intelligent Add-In To Visual Studio about 30 seconds later. Finally…

    After launching VS2008, R# 4.0 Beta asked me a couple configuration-preference-type questions and then I completely stomped on my code until I could recognize it no more.  (Did I mention the full source tree was already imagecommitted to source control?)  

    I played with R# for well over an hour as anonymous delegates became lambda expressions1, object instantiation plus a number of property sets were rolled up into an object initializer2, if statements were inverted, switches became if-else statements, foreachs became to-fors, unused methods were removed, ternary operators were introduced, classes were moved into new files, namespaces were updated and on and on and on and back again.

    I know I’ve only brushed the surfaces of what R# can do (3.1 feature list, 4.0 beta feature list,) but knowing R# offers far more than a ridiculous number of refactoring shortcuts, I can’t hardly wait to start using it as I write new code. 

    One might consider this recommendation premature, but I encourage you to give ReSharper 4.0 Beta a whirl especially if you are new to Visual Studio 2008 and C# 3.* since R# essentially provides you with a painless primer.  (Can’t get your head around Lambdas?  ReSharper 4.0 will create such an expression for you.) It is a quick download and install and it takes only a few minutes to feel the power of the ALT+ENTER keystroke. 

    I hope the Add-in makes coding fun enough to make you giggle.

     

    Example Refactor 1

    private bool IsAliased()
    {
        var computer = computerList.Find(delegate(Computer c)
            { return c.ID == RegistryHelper.MachineID; });
        return (computer.Name != computer.Alias);
    }

    became

    private bool IsAliased()
    {
        var computer = computerList.Find(c => c.ID == RegistryHelper.MachineID);
        return (computer.Name != computer.Alias);
    }
    Example Refactor 2
    Notification notification = new Notification();
    notification.Message = "Message 1";
    notification.Title= true;

    became

    Notification notification =
        new Notification { Message = "Message 1", Title = true };
     
     
    

    SubSonic and SSMS Tools Pack Saved The Day

    Today I woke up feeling uneasy about the direction of my current project.  For all intents and purposes, I am taking an existing system which was pieced together by a couple of past developers and extending it. I’m not saying the code I  inherited was a disaster but I am not going to publicly praise the design and implementation either.  The big problem is the existing system works.

    I know that last statement sounds funny but put yourself in the position of my customer.  They currently have a working product which they wish to extend and private label.  With the core functionality already in place (read: tested with dozens if not hundreds of users,) how much time could/should it take to implement my updates?

    While ramping up, I jotted down a number of areas where the application could be improved but I tabled every task which wouldn’t get me closer to completing my assignment.  In other words, if the change was transparent to my client, I didn’t muck with it — for the most part.

    Which brings me to this morning, approximately two weeks into my development, and my uneasy feeling.  The bottom-line is I made the wrong call.  I should have made the product my own, so to speak, and applied a handful of design changes right off the bat.  If I were completing a simple bug fix, this approach would have been wrong, but since I am scheduled for appropriately 2 months of dev, I can “afford” to make the needed improvements.  It makes sense as it would ultimately save me effort and frustration while costing my customer no extra time or money.  

    Today I talked myself into thinking that refactoring/redesigning would be best for everyone and I promptly redesigned the database (all of it) and swapped out the data access layer (all of it) with the help of SSMS Tool Packs and SubSonic, respectively.  Of course, I had help. Lots of it. Hours and hours of other people’s time…  I’ve written about Getting Started with SubSonic and though I “admire” it, I hadn’t put it to good use until this morning.  SubSonic (after a quick review which consisted of watching this webcast) generated my DAL. SSMS Tool Packs was a lucky discovery as it auto-generated my CRUD routines.  The product offers much more than this and integrates with each version of SQL Server Management Studio, but I only needed stored proc creation today.  All told the entire change took less than 5 hours.  It would have taken far less time if I didn’t have a complete brain fart and chase my tail around an incorrectly established SQLEXPRESS connection string.  Pretty amazing if you ask me!

    To sum things up, thanks to Rob Conery and crew for SubSonic and thanks to Mladen Prajdic for your exceptional contributions.  They really helped me get back on track with minimal investment today.