BizArk Feature Spotlight – String Templates

by Brian Brewder August 06, 2009 22:45

I’ve never liked that String.Format requires you to provide indexed arguments. I’m a bit anal and like my arguments to increase from left to right so that if I add a new argument to the beginning of the string I end up renumbering all the subsequent arguments (hey DevEx, perhaps you can add this to Refactor!?). 

This isn’t too big of a deal for small strings, but it can make it difficult to work with large strings with a lot of arguments, especially when the text and arguments change frequently. To get around this, I often times resort to using named parameters and String.Replace (see the example below).

var str = "{greeting} {name}!";
str = str.Replace("{greeting}", "Hello");
str = str.Replace("{name}", "World");
Debug.WriteLine(str);

Surprisingly performance doesn’t seem to be a major problem with this approach. Iterating 1,000,000 times using string.Format("Hello {0}: {1,2}", "World", i) took ~650 milliseconds vs string.Replace which took about ~900 milliseconds. This might add up to a significant difference in extreme situations, but in most cases it is negligible.

However one major drawback to string.Replace is that you lose the ability to specify formatting in the string which can be very handy, especially when you are dealing with regional formatting issues.

So in order to help with this, I added the StringTemplate class to BizArk which allows you to create a format string that combines the best of both worlds, named arguments along with specifying formatting in the string (see example below).

var template = new StringTemplate("{greeting} {name} on {date:dddd, MMMM dd, yyyy}!");
template["greeting"] = "Hello";
template["name"] = "World";
template["date"] = DateTime.Now;
Debug.WriteLine(template.ToString());

This will print out “Hello World on Thursday, August 06, 2009!”.

StringTemplate actually uses String.Format to format the string so any formatting that you can use in a String.Format argument you can use in a StringTemplate argument. The names are not case sensitive, but they must conform to the same standard as identifiers in C# (upper/lower case letters, numbers, and underscore).

I also created a generic version of StringTemplate. The generic version exposes a property that you can use to set the parameters. If the type has a default constructor, StringTemplate<T> will instantiate it for you (you can also set it if you prefer).  The name of the arguments should match with the name of the properties. It uses the TypeDescriptor class to get the properties, so you can implement ICustomTypeDescriptor if you want. This should make it fairly easy and painless to do mail-merge type functionality.

BizArk is available for download on the CodePlex website, http://bizark.codeplex.com.

The FizzBuzz Interview Test

by Brian Brewder August 02, 2009 12:20

Over the last week I have been interviewing people for a Flash Developer job at my company. This is my first time hiring and it has been an interesting experience.

The first thing that struck me as odd are the number of applicants that didn't come even close to meeting the minimum requirements for the position. The ad said the minimum requirements were 4 years web development experience with 2 years Flash development experience including animation using ActionScript. The ad described the position as a non-design position that will include other development activities as well. Out of 2 dozen or so applicants, only 3 were qualified enough to bother interviewing.

Now it should be said that I'm not a Flash developer, in fact, I've never worked with Flash at all so I was unsure of how to determine if a developer had the experience and ability to do what we need. A portfolio helps, but is not necessarily sufficient to determine coding proficiency.

I am an avid reader of Coding Horror, Jeff Atwoods blog. One of the things that he suggests is administering the FizzBuzz test (the idea seems to have originated from Imran on Tech). I modified the FizzBuzz test a little from the original article, ours went something like this:

Loop 15 times, every 3rd time write Fizz, every 5th time write Buzz, and the 15th time write FizzBuzz.

We also asked the candidate to develop it in the Flash IDE instead of on paper.

When I gave this test to the first candidate, I wasn’t sure what it would prove. It’s such a trivial test that it doesn’t seem like it would prove anything. However, when I watched the candidate perform the test, I learned a number of things about them.

  • Familiarity with the development environment
  • Understanding of basic computer math concepts
  • Confidence in their coding ability
  • Interest and willingness in solving problems
  • Ability to write clean code

I’m a little hesitant to give complex coding problems during an interview. This isn’t the same type of stress that occurs naturally on the job so I don’t believe that it shows how well they work under pressure. However, since FizzBuzz is so trivial, I didn’t feel bad at all about asking the candidate to do the test on our huge conference room monitor in front of me and my co-interviewer.

If you are interviewing a candidate, I would highly recommend giving this test.

Redwerb Visualizers is now on CodePlex

by Brian Brewder June 06, 2009 17:38

I just moved the Redwerb Visualizers project to CodePlex. If you want to download the visualizers, please head over there (Redwerb Visualizers on CodePlex). If you want to report any problems with the visualizer, please use the Issue Tracker on CodePlex.

This is my first CodePlex project. I was pretty happy that I could use my subversion client to access the source code. I purchased a license for VisualSVN (a Subversion client for Visual Studio) a while ago and really like it.

Another nice thing about CodePlex is that you can view the code without having to download it. You can even view the history of the code as well as differences between versions. It may not be as good as Beyond Compare, but it certainly is convenient.

I chose the Microsoft Public License (Ms-PL). This seems to be a simple, straight-forward, permissive license to allow people to use the code any way they want without having to worry about copyright infringement.

Tags:

Tools

Image Visualizer Update

by Brian Brewder May 31, 2009 20:24

I’ve updated the Redwerb Image Visualizer. The Image Visualizer is a Visual Studio visualizer. Visualizers allow developers to view an object in the debugger. Visual Studio comes with a couple of visualizers, but unfortunately, an image visualizer is not one of them.

image

The Redwerb Image Visualizer includes the following features (new features are in bold):

  • Move the image by dragging with the mouse (no more scrollbars)
  • Zoom the image from 10% to 300% (slider is now continuous with several convenient stop points)
  • Change the background of the frame from light to dark
  • View a border around the image (useful if the background is transparent)
  • Includes the following information about the image
    • Height
    • Width
    • Image type
    • Horizontal resolution
    • Vertical resolution
    • Size in memory (an approximation)
  • Quick access to features via keyboard shortcuts (lots of new shortcuts, plus a nicer shortcut dialog)
[Download]

The source code is also available.

Tags:

Tools

Wave Keyboard Review

by Brian Brewder May 17, 2009 15:29

WaveKeyboard I’ve been using the Logitech Cordless Wave Keyboard for some time now and I have to say that I am liking the keyboard. As a developer, I spend a considerable number of hours every day using a keyboard so I tend to be a bit picky when it comes to purchasing a keyboard. Because of this, I almost always cruise over to the keyboard aisle in any store that happens to have one so I can see if there is a keyboard that meets all my requirements.

The Wave keyboard meets almost every requirement. It is ergonomic, has an extended delete key, does not have the F-Lock feature, wireless, arrow keys are arranged properly, and the useless media features don’t get in the way of the operation of the keyboard. The software also allows you to disable the Caps Lock key (as well as a couple others), a must-have feature of any keyboard.

The Wave keyboard is so cool, they even have a “making of” documentary.

 

The one feature that is missing on the keyboard that caused me a lot of problems at first was that it doesn’t have a scroll lock key. I use two computers at home, my personal desktop and my work laptop. I had a KVM (Keyboard Video Mouse) switch that used a double press of the scroll lock key to change machines. Without that key, I had to use a double press of the Ctrl key instead which caused a lot of accidental switches. However, I have since switched to the IOGear GCS22U 2-Port USB KVM Switch. This switch doesn’t have a keyboard shortcut (at least, I’m not using one), but it does have a convenient remote that I can keep next to me that switches the machines.

I have since purchased this keyboard at work, though I upgraded to the Logitech Cordless Desktop Wave Pro. This set includes a mouse with the hyper-scroll wheel. I’ve had once since they first came out and I love having the ability to just whiz through a long page to get to the content I want. The mouse that comes with the standard set is adequate, though you will need to disable the forward button. For some reason they placed the button exactly where I press on the mouse when I am pushing it to the left. I’ve heard this complaint from other reviews as well.

Tags:

Tools

BizArk is Back!

by Brian Brewder April 04, 2009 15:44

I lost the BizArk framework when I changed web hosts, but it is back now. Check out the full list of features on the BizArk page.

There are a few updates since the last release, but unfortunately I don't remember what they are (I made the updates a long time ago, but haven't gotten around to posting them). I believe that I've fixed some problems with the ConvertEx class as well as added some new functionality to it. I've also added some useful extension classes and fixed some problems with the splash screen not working quite right under certain circumstances.

Introducing the Redwerb Image Visualizer

by Brian Brewder April 03, 2009 19:40

I was in need of an image visualizer for Visual Studio today and I was dismayed that I wasn't able to find one that I could just download and install. Don't get me wrong, I found plenty of image visualizers, but they all required me to compile it myself. So I decided to go ahead and build one myself.

ImgVisScreenshot

The image visualizer includes the following features:

  • Scrolls if the image is too large
  • Zoom the image from 10% to 300%
  • Change the background of the frame from light to dark
  • Includes the following information about the image
    • Height
    • Width
    • Image type
    • Horizontal resolution
    • Vertical resolution
    • Size in memory (an approximation)
  • Quick access to features via keyboard shortcuts

 

[Download]

The source code is also available.

ASP.Net MVC is released

by Brian Brewder April 01, 2009 23:13

On March 30th, Microsoft released the MVC (Model-View-Controller) framework for ASP.Net (see the press release). Apparently they have also just licensed the source code under MS-PL (see ScottGu's Blog post), which is an open source license (could this be an April Fool's joke?).

WebForms in ASP.Net is a decent framework for building web applications. WebForms allows you to build web applications in a manner similar to building WinForm applications. This is a powerful concept and one that has made many developers lives better. However, it comes with some cost, especially to how much control you have over the end result.

MVC is an alternative to WebForms that provides the developer more control over how content is rendered, not to mention using a well known, yet underused pattern for building applications with a user interface. One of the features of this pattern is the ability to unit test your code, which can be very difficult to do in WebForms.

Here's the description of ASP.Net MVC from the Microsoft download page:

ASP.NET MVC 1.0 provides a new Model-View-Controller (MVC) framework on top of the existing ASP.NET 3.5 runtime. This means that developers can take advantage of the MVC design patterns to create their Web Applications which includes the ability to achieve and maintain a clear separation of concerns (the UI or view from the business and application logic and backend data), as well as facilitate test driven development (TDD). The ASP.NET MVC framework defines a specific pattern to the Web Application folder structure and provides a controller base-class to handle and process requests for “actions”. Developers can take advantage of the specific Visual Studio 2008 MVC templates within this release to create their Web applications, which includes the ability to select a specific Unit Test structure to accompany their Web Application development.

The MVC framework is fully extensible at all points, allowing developers to create sophisticated structures that meet their needs, including for example Dependency Injection (DI) techniques, new view rendering engines or specialized controllers.

As the ASP.NET MVC framework is built on ASP.NET 3.5, developers can take advantage of many existing ASP.NET 3.5 features, such as localization, authorization, Profile etc.

For convenience, here are some of the resources available out there for ASP.Net MVC:

From Mix 09 (list of all videos). I haven't seen all these videos yet, but here are the ones on MVC:

Tags:

New Job

by Brian Brewder March 29, 2009 16:29

On February 2nd, Groundhogs Day (3rd favorite holiday :), I started a new job. I am now the Vice President of Product Development at TourFactory, a small company based in Spokane. They provide a web-based service to real-estate agents to help them market the homes they are selling.

The application is built primarily in classic ASP and I've been a bit nostalgic over the years for the simplicity of that platform, but I'm over that now :). I can't wait to begin the process of converting the product to .Net (one of the reasons I was hired). Classic ASP is simple, unfortunately it's a bit too simple. There is not very good support for debugging or Intellisense and there are many language features that I've grown accustomed to in my years as a .Net developer that are missing.

So far the job has been great. The people there are very easy to work with and are excited about some of the changes that I want to make, especially to the deployment cycle (more on this in another post).

This is my first management position, but I only have to manage 3 other developers, so hopefully I will be able to handle it. I've had the opportunity to work for a couple of great managers that I really respect over the years, so hopefully I have picked up a few good habits from them.

For those that know me, I still live in Arlington Washington, a town over 300 miles away and on the other side of the Cascade mountains from Spokane. I work every other week in Spokane and am in the process of getting an apartment there.

Spokane is a neat city to work in. You can get through most of downtown without going outside through a series of pedestrian walkways that go through many of the buildings. This is nice because it can get pretty cold in winter and awfully warm in summer. There is also a nice park within a couple blocks of the office that includes rides, trails, trees, a river, and more. There are also a bunch of restaurants in the area that look pretty good, though I've only had the opportunity to go to one so far.

The building I work in is the Fernwell Building. It was build in 1891, almost 120 years old! Thankfully the building does have electricity, air conditioning, and fiber optics. It is a nice building and has been well maintained. My office is on the 3rd floor, far left corner (see picture below).

Fernwell

Tags:

Internet Explorer 8 has been released

by Brian Brewder March 19, 2009 08:54

If you haven't heard yet, IE 8 was released today (March 19th) at 9am (PDT). IE 8 is supposed to be faster and more standards compliant than its predecessor. However, there doesn't seem to be any big, noticeable improvements to the browser like there were in IE7 (like tabbed browsing) so it will be interesting to see what the adoption rate for IE 8 will be.

Download Internet Explorer 8

If you like following the browser wars, Firefox 3.5 (codenamed Shiretoko1) seems to be just around the corner. This is a major update to the current version of Firefox (3.0).

1. Shiretoko: according to Wikipedia, this is an Ainu word meaning "end of the earth".

Tags:

Tools

Powered by BlogEngine.NET 1.6.0.0

About the author

I've been a software developer since 1999 and have been working with .Net since 2002. I love creating software, playing with productivity tools, and improving the process of software development. I hope you enjoy my blog. Please feel free to leave comments or contact me, I would love to hear from you.