Friday, August 17, 2007

Good Documentation

I don't think it is a coincidence that my favorite development tools are so well documented. The only reason they kept my attention long enough probably has more to do with their level of documentation than their level of "coolness".

Direct links to documentation for some of my favorite tools.

Submit this story to DotNetKicks

Thursday, July 26, 2007

String formatting tips for C#

Handy guide that I've perused once or twice for tips on formatting strings in C#.

String Formatting in C#

Submit this story to DotNetKicks

BizTalk 2004 Links

A wealth of useful BizTalk 2004 information can be found at Gille's WebLog.

Another good resource that takes one of Gille's posts even further and demonstrates how to unit test a mapper.Automated Build & Deployment

Submit this story to DotNetKicks

Will My Software Project Fail?

There are a lot of reasons typically given for software projects failing, poor management, lack of requirements, and lack (or excess) of talent are common reasons I've heard(used) for failed projects that I've witnessed(particpated in).

Coding Horror has an excellent article that presents 3 alternative reasons that projects may fail that might not be intuitive at first.

Will My Software Project Fail?

CH presents three new pillars of successful software projects.

  1. Version Control
  2. Work Intake Management
  3. Build System


These are three things that I've lobbied for in every project I've ever worked on, even when I couldn't articulate what I wanted because I hadn't yet seen it in action.

Submit this story to DotNetKicks

Monday, July 23, 2007

VS.Net: Trim EOL White Space

Regular expressions are great. Little strings of yummy helpfulness.

Here's a little regex that can be used to trim all some or all of your trailing whitespace.

:b+$

Just pass nothing for the replacement.

Submit this story to DotNetKicks

Shared Server Etiquette

  1. Log off

    Don't stay logged into shared machines, log off when you are done. The performance overhead of multiple logged in users is bad enough when we're all working, but do we really need 4 instances of ScrnSve.exe running too? Also, if you're logged in but unavailable then managing the machine is more difficult if a reboot needs to be done or other system maintenance. And for Knuth's sake, please don't stay logged in over night.


  2. Disable the screensaver.

    Sure, we can't be constantly logging in and out, there are times we will be working for extended periods of time on the shared server and may be pulled away during that time. No sense in running another application whose only purpose in life is to burn cycles and render pretty pictures when no one is looking.

Submit this story to DotNetKicks

Sunday, July 22, 2007

TextPad Regular Expressions: Replace Leading Whitespace with ' '

TextPad is my text-editor of choice. It's simple, fast and lightweight. Plus it supports regular expressions and wildcard searches.

When preparing a post for upload onto the site I often need to replace the leading whitespace with HTML encoded whitespace. This replacement will have to be run for leading whitespace character you wish to replace, but don't worry TextPad will let you know when there are no more replacements to be made.

Inside the TextPad Replace dialog ... (Don't copy the quote marks!)

Find what:  "^\(\(&nbsp\;\)*\)[[:space:]]"

Replace with:  "\1\ "

To restore the whitespaces use the follow expression.

Find what:  "^\(\([[:space:]]\)*\)&nbsp\;"

Replace with:  "\1 " <-- Notice that there is a single space character after the \1.

Submit this story to DotNetKicks

Thursday, July 19, 2007

TDD? You've got to be kidding me?

Just taking another peek over to the the Sun's side of the Sun/Microsoft fence and checking the color of their grass.

Another tool for testing the reliability of your tests is Jester. This tool will actually tweak your code as your unit tests are executed to see how well the tests hold up to changes.

There's already a C# port named Nester. I'm definitely going to try to integrate this into my CI process.

I have to admit, this isn't going to be funny (heh, wocka-wocka-wocka) the first couple times but it'll be interesting to see where it takes my code.

Submit this story to DotNetKicks

If yer code ain't tested, the waterfallists win.

Just reporting on untested code is nothin'. How about a tool that *removes* untested code.

Check out the oh-so-provocatively named coverage tool, Guantanamo.

When Guantanamo detects untested code it will actually remove it from a working copy of the codebase. C'mon, if you want to move from the foo-foo world of XP and into the hardcore world Mountain Dew level of extreme it should remove the code from source control. Currently the tool is only available in the Java world, but with most of the XP tools stack (ant, junit, cruisecontrol, jcover) will eventually find it's way into the C# world.

If you're wondering about the quality of your unit tests, and are in the Java world, check out Ashcroft. The same guy who gave us Guantanamo also created this tool for analyzing your unit tests. By checking your tests against a set of guidelines your testing practices become more focused and streamlined.

They are building a 10 Commandments of Unit Tests, here's a direct quote from their site.

  1. I am the class being tested. Thou shalt not test any other class but me.
  2. [Thou shalt write isolated tests]
  3. [Thou shalt not access files during unit tests]
  4. [Thou shalt not write two tests which depend upon each other]

This is good stuff, and I'm looking forward to more of these kinds of tools in the .NET world. Sure we have VS.NET and it's a great tool, but it seems like everything we have is clones of stuff from the Java universe. Are there any tools really unique to .NET that didn't originate as a direct reimplementation of a Java tool?

Submit this story to DotNetKicks

Monday, July 16, 2007

Know what's cool? Blogging from your installer is cool.

The pendulum is swinging back towards Linux again for me. As my wife has noticed and much to her irritation, every couple months I'll take another shot at replacing my Microsoft... er, I misspelled that, I meant Micro$haft (now I'm 133t), operating systems with one of the more popular Linux distributions. Over the years I've tried Red Hat (v4 was my first attempt), SuSE, Mandrake, Lindows (I think it's now called Linspire), Caldera (now SCO, those bastards) and an old Corel distribution. Mostly with varied levels of failure. Until Red Hat started the Fedora project, most of my attempts at converting to Linux we immediate dismal failures at best. There was always some level of ridiculous flakiness or some quirk that would irritate me enough to throw my hands up and run back to the known-devil that is Windows.

My current experiment is with Ubuntu 7.04, installed with the DVD included in a Linux Format magazine. The magazine is an excellent read and worth picking up even if you're a hardcore MS developer. But to make their magazine even cooler, each issue contains a content disc that usually has the latest version of several distributions. It's much easier just to spend the $15 and read the magazine while the installation chugs along, than to fight with downloading an ISO and discovering it was corrupt only after you began the install. But the magazine isn't why I'm blogging. I'm blogging because I am so throughly blown away by the Ubuntu installation experience.

Ubuntu has an amazing installer. They load the operating system as a live cd, basically running the OS directly from the DVD. You can then play around with the distribution before you fully commit to installing the OS, and if you decide to commit you just click the "install" icon on the desktop. A few more clicks through the wizard and you are on your way to Ubuntuy Linux goodness. The really fun part is that you can surf the web while the installation is running because the live cd loads all the drivers automatically. So I was able to blog about how awesome the Ubuntu installation experience is while the installation is running! Neat! Funny that installing an OS could be easier than installing some common desktop application.

Submit this story to DotNetKicks

Friday, July 13, 2007

Save money on Microsoft tools and systems.

Microsoft Action Pack

Microsoft Empower for ISV's

Submit this story to DotNetKicks

Saturday, July 07, 2007

Save streaming music to disk from WinAmp using Streamripper

Streamripper is a plug-in for WinAmp 5.0 that will allow you to save streaming music to disk. Simply download the latest version and run the installer. When you start WinAmp an additional window titled "STREAMRIPPER" will be open as well. While listening to a stream that you want to record, click the start button in the Streamripper window. StreamRipper will beging to save the files in a folder on your desktop by default. To change the location of the save folder, click the config button in the Streamripper window, select the File tab and change the output directory to wherever you want Streamripper to save to.

A thorough tutorial on how to use Streamripper with WinAmp can be found here.

Submit this story to DotNetKicks

How to automatically embed DotNetKicks "kick it" links into your Blogger posts.

DotNetKicks is a social bookmarking site, kind of like Digg but targeted at .NET developers. The stories are moderated using a democratic system where articles get votes, called kicks. The more kicks you get the higher up you move in the story hierarchy. When a story is submitted it starts in a pending stories queue. If you get enough kicks your story will be moved from the pending stories queue to the front page. This might all sound like fun and games but what really perked my ears up was their integration with Google's AdSense to earn money for submitted stories. DotNetKicks will split 50% of the ad revenue for clicks through to stories you submit. Nice.

The trick is getting submitted, if your readers aren't aware of DotNetKicks they won't know to submit and/or Kick your articles. You need a way to let them know about the site, but without being crass about it. I didn't want to manually submit my post every time I blogged, so I used Blogger's template system to help do it for me.

<p><a expr:href='"http://www.dotnetkicks.com/submit/?url=" + data:post.url + "&title=" + data:post.title' expr:id='data:widget.instanceId + "_kickit"'><img alt='Submit this story to DotNetKicks' expr:src='"http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=" + data:post.url'/></a></p>

I created a tag that I inserted into my Blogger posts template that will automatically display the number of kicks the article has received so far. If you click on the link and the story hasn't already been submitted you will automatically be redirected to DotNetKicks article submission page with the link and title already filled out for you. If the story has already been submitted your vote will be added to the kicks counter.

To add the tag into your post template go to the Template tab under your Blogger accounts Customization section. Select "Edit HTML" and check the "Expand Widget Templates" check box. Scan the template until you find a line that looks something like "<p><data:post.body/></p>". That is where the Blogger templating engine inserts the body of your post. I inserted my tag to appear directly below the body of my posts but you can play around with whatever position you like by using the "Preview" button. You'll have to save the template to apply the changes when you are satisfied.

PS, I used the above steps to post this article to DotNetKicks.

Follow up: The URL changed for submitting links, the snippet in the article has been updated to output the correct link.

Submit this story to DotNetKicks

Friday, July 06, 2007

Programming without source control is like coding without pants.

Sure, I can code with no pants on. But if I'm working on a team it's better if I put on some nice slacks.

Submit this story to DotNetKicks

Wednesday, July 04, 2007

One Shall Stand, One Shall Fall

I just got back from seeing the Transformers movie. All I have to say about that is, "Mr. Bay I am sorry for doubting you." This is what summer popcorn adventure movies are supposed to be. Simple, straight-forward action, driving music and just enough humor and light romance to keep it fun. And gigantic robots smashing the shit out of each other.

Personally, I have quite a history with the Transformers franchise. The first thing I ever purchased with my own money was a first generation Optimus Prime. I had to do chores at my father's truck shop for several weekends before I saved up enough money. $13.00 American. As with all children's fancies I eventually traded him for a new Rodimus Prime around the time of the first Transformers movie. Big mistake, Rodimus was never as much fun as Optimus.

I'm pretty sure I did more than my fair share of whining and wheedling whenever my mother got too close to the toy section, but my biggest showdown with my mom was over the Transformers movie. We were at a Jewel that had a video rental center towards the front of the store that was carrying the object of my desire. I don't recall the entire event completely, but I'm sure it went something like this. As my mother entered the cashiers line to pay for our daily bread when I began my attack. She was informed of the movie and just how important it was, but she resisted. As she packed up our groceries and moved out towards the door I realized the object of my desires was not in our possession, I became frantic. I remember stomping and crying and yelling that I was being abused and she probably didn't love me or care about me. She kept her will and I didn't get the movie that day, but I like to think I put up quite the scene. I have to admire her fortitude, I was quite the showman.

Autobots, transform and roll out.

Submit this story to DotNetKicks

Monday, July 02, 2007

Naming Conventions for Project and Solution Folders

Small Solution Structures

If the project space is small I'll just name the folder and solution to match the fully-qualified namespace.

Folder
c:\FrogsBrain.MyFancyPants

Solution
c:\FrogsBrain.MyFancyPants\FrogsBrain.MyFancyPants.sln

Namespace
FrogsBrain.MyFancyPants

Larger Solution Structures

If the solution directory tree is very deep or there are many projects are under the root namespace I will break the solution folders up to remove redundant uses of the root name.

Folder
c:\FrogsBrain\MyFancyPants

Solution
c:\FrogsBrain\MyFancyPants\MyFancyPants.sln

Namespace
FrogsBrain.MyFancyPants

This will help keep to avoid errors when a path can get too long and wreak havoc with some source control tools.

Project Structures

The project names will follow suit, leaving out the name of the solution.

Folder
c:\FrogsBrain.MyFancyPants\Library
OR
c:\FrogsBrain\MyFancyPants\Library

Project
c:\FrogsBrain.MyFancyPants\Library\Library.csproj
OR
c:\FrogsBrain\MyFancyPants\Library\Library.csproj

Namespace
FrogsBrain.MyFancyPants.Library

Output
FrogsBrain.MyFancyPants.Library.dll

The exception is that the project output will be the fully-qualified name of the project. This makes identifying the assembly easier and prevent collision of names like Library.dll.

Folders Not Divided By Namespace

Inside of projects I try to follow the same structure but if a folder is not to be included in a namespace or I want to group some files without changing the namespace structure I will create a folder with a "_" prefix.

Project
c:\FrogsBrain\MyFancyPants\Library\Library.csproj

Folders
c:\FrogsBrain\MyFancyPants\Library\_build
c:\FrogsBrain\MyFancyPants\Library\_configuration
c:\FrogsBrain\MyFancyPants\Library\_documentation
c:\FrogsBrain\MyFancyPants\Library\_contracts\ISomeView.cs
c:\FrogsBrain\MyFancyPants\Library\_service\ISomeService.cs

Namespace
FrogsBrain.MyFancyPants.Library

Output
FrogsBrain.MyFancyPants.Library.dll

All files inside of "_" prefix folders are considered to be in the same namespace as their parent folder.




I've tried variations of these structures but will be implementing this as the standard structure for all projects I am responsible for in the future. It's the cleanest and easiest to manage layout I've worked with and has grown from experimentation over a couple years. So, if you look at some of my code and it doesn't already follow this pattern it will eventually.

Submit this story to DotNetKicks

Structuring NAnt Buildfiles For CCNet builds.

I get all verklempt over automated builds. The usefulness of scripting your builds and running them on an automated system cannot be overstated. Period.

Preventing bloat and keeping your builds in sync with the code base is difficult if you don't keep them close. Typically code will be split into separate files to make it more maintainable, build files are no different. I've found that a single build file for anything but the simplest project can grow very unwieldy quickly but by keeping only one coordinating build file at the solution level and splitting the builds up by project, automated builds can be easier to implement and manage. Also, by keeping the files alongside the code they are the building the builds stay in sync with the code they are building.

For example, I have a solution containing 3 projects. One is an executable, two are libraries. The folder structure and the naming of the solutions typically follows the structure of the namespaces.

Let's work from a root folder named 'source' sitting on C:.

c:\source

Inside of here I have a solution folder named FrogsBrain.MyFancyPants, the solution will match the name of the folder.

c:\source\FrogsBrain.MyFancyPants\FrogsBrain.MyFancyPants.sln

I'll go ahead and add my standard folder to hold my master build script.

c:\source\FrogsBrain.MyFancyPants\_build\FrogsBrain.MyFancyPants.build

The primary concern of this build file will be to call the project builds in the correct order and perform any global configuration for those projects.

Now I will build the project folders.

c:\source\FrogsBrain.MyFancyPants\Library\Library.csproj

And this too will contain a folder for it's respective build file.

c:\source\FrogsBrain.MyFancyPants\Library\_build\Library.build

The pattern will be repeated for the other two projects.

c:\source\FrogsBrain.MyFancyPants\Library\UI.csproj
c:\source\FrogsBrain.MyFancyPants\Library\_build\UI.build
c:\source\FrogsBrain.MyFancyPants\Library\Tests.csproj
c:\source\FrogsBrain.MyFancyPants\Library\_build\Tests.build

VS.Net Solutions can hold items that are not inside a project. Unfortunately, whenever you just add a Solution Item, VS.Net will ignore the folder structure and link to the item directly underneath the solution name. To imitate your physical folder inside your solution, add a new Solution Folder and name it '_build' to match your physical folder, then add the master build file as a Solution Item inside that folder.

Now your VS.Net Solution will look like...

FrogsBrain.MyFancyPants
    _build
        FrogsBrain.MyFancyPants.build
    Library
        _build
            Library.build
    UI
        _build
            UI.build
    Tests
        _build
            Tests.build


Now your build files will be added to source control and versioned alongside the code they are building. This will make executing automated builds easier because the location and naming of the build files will be standardized, making the process easier and more repeatable.

Submit this story to DotNetKicks

Expanding My Source Control Horizons.

I have really enjoyed using SourceGear's Vault source control server for all my personal development needs for quite a while and I have been nothing but happy with them, I need to expand my horizons.

What I really like about SourceGear, aside from their excellent products, is that they seem to really get how to cater to the small, independent software developer. By providing a free single-user license they put themselves within reach of the developer who could not otherwise afford their product. They also are owned by an individual who really seems to know how to communicate with developers on their level. Through his blog about the daily issues of his software firm and excellent book, Business of Software, which I own and recommend picking up. Also, they support developers desire to extend their products with an automation API and a set of NAnt extensions.

But comfort breeds complacency. I need to try new stuff and see what's out there.

The world of source control tools has seen a surge of growth and even better, competition over the past couple years. The list of actively developed source controls tools, that are within the reach of a mere mortal developer, has grown tremendously and the choices are all very attractive.

So, I've decided to play around with a couple vendors that have licenses that appeal to me. So here's a brief description of what I want in terms of features and licensing.

Cheap, or at least reasonably priced, since I'm not writing packaged software for sale at this point, I'd like a vendor who has discounted licenses for open-source software developers and teams. I like to constantly merge/check-in my code to the repository so having to break flow by leaving the comfort of VS.Net is not desirable. Also, I don't like having to memorize the command-line utility, I am a GUI brat and although I've worked with services and console apps for years I prefer managing the server via some form of GUI, web-based or standalone application doesn't matter. There also needs to be the ability to integrate with CruiseControl.NET and NAnt. Also, labeling needs to be easy, branching and merging of branches should be simple operations. The creation of repositories and working structures needs to be painless. Checkins needs to be atomic and transactional, individual pieces of changelists need to be easily rolled back and commit failures cannot corrupt the repository.


I know that my needs are very MSDevcentric. Hey, it's my list, if you want stuff for whatever platform you work in then that's your wish-list. So basing my requirements off that list I've looked around and have picked a couple tools that I am going to evaluate and report on before I decide whether to just stick with Vault or begin using another tool for my everyday use.


  • Perforce

    Very attractive open-source developer friendly licensing. An excellent book that covers Perforce as a tool is The Build Master which I own and have read.


  • Subversion

    CollabNet binaries, can't beat the license, FREE! I don't own this one yet but will be ordering it from Amazon. Version Control with Subversion


  • Visual Source Safe 6/2005

    From personal and painful experience, "Blech". I inherited it at my job but it's better than everyone working off a shared folder.


  • SourceGear Vault

    What I currently use, but will list it's merits. Vault is also covered in Coder to Developer, which I read cover-to-cover but then gave away as a gift to an excellent Agilist developer when he moved on to another company. Also, I think it's where I first heard about Vault.


  • Team Server

    I love me some CodePlex, best place for MS-based OSS projects I know of but I'm going to focus on the SCM aspect.


  • Surround SCM

    The current likely candidate for replacing VSS at work.



As I work through the different tools for the next couple weeks I'll update on my experiences using those tools in my day-to-day development tasks.

Submit this story to DotNetKicks

Wednesday, June 27, 2007

Tsst.

Every wonder what career a character like Cartman might gravitate towards when he grows up? If you said Project Manager then you probably work as a developer too. Pushy, whiny, demanding, self-centered and glad to criticize you while you are working.

Well, the trick is to assert your dominance and become the alpha dev of your team. Not that you want their job, just that you need to assert that you are a confident professional. But unlike Cartman's mom, you can't actually pinch your PM's in the neck. What you can do is assert your own authori-tay.

If your PM has as much willpower to control work intake as a greedy little piggy then you need to take action. Tsst! They need to flip the words around in their title and learn that if they don't want to look bad they need to "manage projects". It's not your fault they promised that the invoicing changes, website updates, database optimization, customer xyz's customizations and anything else they see lying on the ground while walking to their desk, would all be done by Friday; it's theirs. Sit down with them, list the projects they want to accomplish and figure out what you can finish by Friday. Then work out what it will take to accomplish the entire list. They can then take that to whoever they swore their first born to about that Friday deadline and take their lumps. Don't work overtime just because they cry "but maaa-aam, I want you doo eet, whaaa!". You are only reinforcing negative behavior. Overtime should only be allowed in the case of actual emergencies and by emergency I mean that space aliens and the government are somehow involved.

Pretty soon they will get used to actually working WITH you to plan their projects. And with patience and proper manager training, you will win the war and find yourself in an agile shop without a single shot being fired*.

*Or you'll be fired. This is insanity, I am an insane person. If this works for anyone then they should get their own television show.

Submit this story to DotNetKicks

Clumsy Development

Basically it's the George Costanza model of software development. The only requirement is to know the vocabulary, not that you need to know what the words mean though.

For example.

Agile says to not have constantly changing priorities while expecting your developers to change on a dime.

Clumsy says, the more projects the better, what else are the developers going to do with their time? Test, bah!

Agile says to keep meetings to a minimum.

Clumsy says that whoever passes out from lack of oxygen first wins.

Agile cares about the developer's quality of life and acknowledges that it is important for the long term success of the project.

Clumsy says "Whip the horse until it's dead." (This I have on reliable hearsay was an actual statement made by someone with a very fancy title and doors on his office.)

Submit this story to DotNetKicks

Heroic Developer, the Saga Continues.

Continued from Heroic Developer.

*Deep Breath* If you find yourself working on some half-baked idea concocted by your project manager as they were on their way out the door at a 4:55 PM until midnight for more than zero nights in a row. Then you might be a Heroic Developer. *pant*

Submit this story to DotNetKicks

Tuesday, June 26, 2007

Programmers Bill of Rights

Coding Horror posted an article in 2006 that proposed a Programmers Bill of Rights. I've worked at some pretty messed up places that violated all or most of these "rights". Although I know that the word "rights" was used in a tongue-in-cheek manner the point was that these things make sense. Calling it a "Bill of Rights" was meant to get the readers attention, but it's fair to call the list "Common Sense". To be fair, most of these things I'd be happy to get myself if I'm paid well enough, but somethings can only be provided by the employer, such as the quiet working conditions and fast internet connection.


  1. Every programmer shall have two monitors

  2. Every programmer shall have a fast PC

  3. Every programmer shall have their choice of mouse and keyboard

  4. Every programmer shall have a comfortable chair

  5. Every programmer shall have a fast internet connection

  6. Every programmer shall have quiet working conditions

Submit this story to DotNetKicks

Heroic Developer

Look, over in the cube. It's a nerd. No, it's a geek. NO! It's Heroic Coder. Coding longer than a puny developer! Introducing bugs and errors faster than a marketing drone can dream up the next greatest feature. HEROIC CODER!

Seriously, how long can we take it? If the manager can't plan the project based on sustainable and healthy working hours over time, then you need to push back. Just because you can work late into the wee hours of the morning and over the weekend doesn't mean you should. Take a break, go home and drink a cup of tea. Go for a walk and read a (non-technical) book. Your brain needs a break. Spending too much time trying to hack in another knee-jerk requirement is going to end up taking longer and wear you out, leading to increased mistakes and a myopic view of the problem. That tunnel-vision and fatigue will only add up to having to spend more time later debugging a rapidly deteriorating code-base while still trying to shoehorn in yet another new feature. It's a vicious cycle and it's up to you to break out of it and take on the mantel of "Professional Developer".

Heroics == Hours Spent
Professionalism == Effort Maximized

Submit this story to DotNetKicks

GWDD

Greasy-wheel Driven Development

All development is driven by whomever is screaming loudest. Project priority is determined through a bidding type system where the competing requests are escalated up to the next highest person in the management chain. Progress is managed by continuous nagging and veiled threats to whatever resources are assigned to, or at least coerced into working on, the issue.

See also ADD.

Submit this story to DotNetKicks

Automated code formatting tools

I love automated code formatting tools. Anything that will help clean the layout of code, especially code that I've inherited, is a major productivity booster.

I've been a bit of an evangelist for ReSharper in every development team I've been a member of. If the only thing ReSharper provided was code formatting I would still recommend it. It provides a great deal more which I'll cover some other time. ReSharper has granular enough code-style rules tools that should satisfy almost any possible team standard for code layout. The rules can also be imported/exported which is a time saver when you work on several machines or in a team. ReSharper is one of the few tools I've bought out of my own pocket and will be happily upgrading my 1.x license to the new 3.0 version very soon.

A classic free tool is GhostDoc. It doesn't reformat your code, but it will clean up and generate the xml documentation for methods, constructors and properties. It's very handy when you are maintaining code that doesn't have any xml comments to select "Document This" from inside the method and have the template filled out for you.

A new tool that seems very promising is Regionerate. It will automatically organize your C# class properties, fields, constructors, events and methods into neat regions with nice labels that contain a count of the number of items in that region. Very slick.

Submit this story to DotNetKicks

Monday, June 25, 2007

The Play

The actors are assembled for the Writer's play. Some will play heroes, and some villains while most will walk through the scene forgotten and unheard. The Director moves the actors through the tragedy and comedy and the quiet moments in-between. When the script is done and the speaking stops the curtains draw and the all is ended. The cast is called to take a bow, is the villain still applauded? Or is he taken away and punished for his role? Is the hero to be knighted? The Writer wrote their deeds and they played their part as it was already decided. Who will be invited to the post-production party?

Submit this story to DotNetKicks

Friday, June 22, 2007

How would you unit test this?

if ( Jack.WorkQuantity == "All"
    && Jack.PlayQuantity == "No" )
{
    Jack.BoyType = BoyTypes.Dull;
}


It's a trick question, the answer is "Don't." Go outside, nerd.

Submit this story to DotNetKicks

Polish PM stands up to Germany

Germany is pushing for the votes of EU members to be based upon population. Which is not surprising considering that Germany has the highest population on the European continent, second only to Russia. Poland, in a welcome change of attitude to it's typically acquiescent nature, has unleashed a blitzkrieg* attack on the German argument.

The Polish PM has pointed out that the population of Poland was horrifically decimated by the Germans during WW2. The situation in Poland would be quite different as the fallout from the 1939 to 1945 war, which slaughtered over 6,000,000 in Poland alone, has left them in a weakened state that they have never fully recovered from.

I'd like to point out that the Soviet Russian occupation of Poland for decades after the war only further exacerbated the problem. Which is still to the point because it probable wouldn't have happened if it weren't for the original German aggression.

Quote from the thisislondon.co.uk article.

Poland has been fighting plans for the summit - being held in Germany - to change the EU's voting system to one based on population.

It would increase the influence of the host country, EU's largest with 82million people, at the expense of smaller members such as Poland, which has only 38million.

Mr Kaczynski stunned other EU leaders by claiming that Poland has 28million fewer people than it should have as a result of the slaughter inflicted by Germany between 1939 and 1945.

Area and population of European countries

*pun, somewhat intended. :-)

Submit this story to DotNetKicks

Friday, May 18, 2007

[Linky] HOW TO: Debug into a .NET XmlSerializer Generated Assembly

When using the xml serialization object to serialize and deserialize an object a temporary class file is generated. This article explains how to find the intermediary file and step into it with the VS.Net debugger.

Article by Scott Hanselman.

Submit this story to DotNetKicks

wut it looks liek

thiss wut it luks liek wien my wife not edit my posts

nerf

^_^

Submit this story to DotNetKicks

Thursday, May 17, 2007

From hard-sell to conversation

Interviewing is like selling a used-car. Only, instead of a jalopy, you have to pitch yourself or your company. You must negotiate the buyer’s eyes away from the patches of rust and the little ding on the door, and instead get them to notice the powerful, efficient engine and high gas mileage. It requires you to look on the bright side of everything, while carefully dancing away from the edge of lying.

I used to think interviewing was fun, even intellectually stimulating; a battle of wits where you had to be on your best behavior and use your imagination and experience to stay a few steps ahead of your inquisitor; an artful journey of remaining within the realm of truth and honesty but without contemplating on your shortcomings open to another ones judgment.
Politicians and salesman have tough jobs if they're really honest, but not many of them would know that. Now, interviewing to me is drudgery, a painful task that leaves me emotionally and physically exhausted. I'm tired of interviews.

What can be done to move away from the car lot and into the realm of a creative professional? How can we change from the hard-sell tactics to a human conversation?

The first step would be to change the formal gauntlet of questions into a conversation. I always felt like everyone is working off the same question sheet for interviews. Like a standardized test where if you take it enough times you'll start recognizing questions and end up just reciting rote answers from memory. Make it a conversation.

Interviewer, instead of asking whether the candidate has worked with X technology or Y system, talk about what your company is doing. Describe the projects you are working on, even the problems you ran into and how you overcame them (or didn’t). Tell a story about the job and the people you work with. Be open. Don't just blurt out "Tell me a story about a time you overcame a difficult problem." as so many interviewers have done to me in the past; tell the person you are interviewing about some of the problems you may be encountering on a project and see what they have to say. You may discover, your interviewee having a creative side that is able to understand and share in the conversation. However, if your interviewee stares at the horn that apparently is slowly growing out of your forehead, then maybe the conversation is done. Interviewer, understand that you are the one who is actually in the hardest situation. You are the one who needs someone to do something. Asking a pre-fabricated list of questions isn't going to grant you a good colleague, co-worker or employee. What will grant you those things is a more personal exchange.

Interviewee, don't be afraid. You aren't a passive participant bracing yourself for the next wave of questions. Ask your own questions. Be prepared to be an active participant in determining if this job is as good as the blurb said it was. You wouldn't buy a car based only on the description in the advertisement, would you? You would ask about mileage, whether the car was in an accident, and what type of guarantee does the dealership offer. If you can question a car salesman then why would you not do the same with your interviewer? You need to know if this job is the right fit for you, what kind of hours will you work, what tools will you have at your disposal, and is there a coffee machine in the break room?

Interviewer, if you depend on pre-fabricated questions, then consider the standardized test scenario. If the questions are expected by the interviewee, then the answers are easy to memorize and rattled off by rote.

Interviewee, the danger for you is the deception of omission on part of the interviewer. If you passively depend on the interviewer to guide the interview, then you may not find out about the 80-hour work week until well after the time for graceful exit has passed.

Conversations are generally hard to fabricate because of their constant state of give and take. Because conversations are free-form, the ideas and statements can be followed up on or questioned. It is harder for someone to dance through the field if they don't already know where the mines are buried.

Finally, Interviewer, get rid of the gauntlet. Make it a one shot deal. A good conversation is cohesive and fluid. It can’t be broken up into a number of sessions with various people who often repetitively ask the same questions that I just answered in a previous session. I find it the most exhausting, having to sit down and go through the same introductions a half-dozen times only to be passed like a relay-baton to the next runner. Conversations can ebb and flow but they are constant. If you can’t have everybody show up at once, then bring them in while keeping the conversation going. Interviewer, if you have to collaborate with a half-dozen parties, post-interview to discuss their impressions, why not just get them all together for the interview itself?

In the last several years, I’ve only had one interview that felt like a real conversation. Some standard questions were asked, but for the most part the interview was done by several programmers and team leads asking questions and talking about the job. It was a memorable experience that left me wanting to work there. Things changed however. Outside influences seeped in and negative behaviors were encouraged causing openness and idea sharing to no longer be valued and ultimately abandoned. As a result, I am interviewing again. I'm reflecting on the positives that this company had and the reasons why I wanted to work there. And I must say, it was my interview; a little conversation I had with some people about a job they were doing.

Now, I am back on the car-lot listening to the same old spiels , but what I am really looking for is a good chat.

Submit this story to DotNetKicks

Saturday, May 12, 2007

What is "done"?

Back when I was just getting my teeth into agile software development I was confused as to when a project can be considered done. Some colleagues said that when it was good enough or when they stopped being paid; but most of the definitions were too vague and indeterminate. When can we step back and safely say that all the necessary steps for producing a quality product have been satisfied? I sat down and considered all the "musts" and "shoulds" from a variety of sources and created the following list.

What is “done”?

Done is…


  • … the software has been written to address the requirements of the end-user. No more, no less.

  • … the software has a suite of tests written to exercise and validate that it meets the requirements and is technically valid.

  • … the software’s source code has been reviewed by a peer, preferably peers.

  • … the software’s source code meets the development teams coding standards.

  • … the software’s source code has been factored into logical and easily readable sections.

  • … the software’s functionality has been tested by integrating it into the system it will reside.

  • … the software’s functionality has been documented and described for future developers and users.

  • … the software has been tested and reviewed by a quality assurance expert.

  • … the software has appropriate installation and/or configuration procedures created and documented.

  • … the software’s functionality has been verified as meeting the requirements of the end-user by the end-user.



Special thanks to Derik Whittaker for digging up this document, the original is archived on some backup disc that I will have to find eventually but it was written in the Autumn of 2006. Click over to Derik's blog and read some of his stuff, it's worth your time. Derik Whittaker's blog.

Submit this story to DotNetKicks

Friday, May 11, 2007

I'll never understand some things.

For example, how a multi-faceted and dynamic woman like my wife could possibly think that being married to me is a good thing. The narcotics probably help, but still.





Powered by ScribeFire.

Submit this story to DotNetKicks

Tuesday, May 08, 2007

Shorpy | The 100-Year-Old Photo Blog

Wow, just wow. Amazing photos dating back to the late 1800s. Images range from recreation by the pool to slave pens to hobos and tramps to early baseball club members. And an easy to navigate site, definitely worth spending some time browsing through the images and realizing just how good the "good ole days" weren't.

Shorpy

Feeling very, very grateful for my great career right about ... now.

Submit this story to DotNetKicks

Monday, April 30, 2007

#Résumé

An HR-XML compatible résumé API for creating and manipulating standardized resume formats. The API is implemented in .NET 2.0 using C#.

Learn more about the HR-XML Consortium here.

Download #Résumé from CodePlex here.

The initial release is the most basic implementation for generating basic resume format documents.

Submit this story to DotNetKicks

Friday, April 27, 2007

VladStudio: Excellent Desktop Wallpaper Resource

I'm a little neurotic about my desktop wallpaper. As a developer, I spend an inordinate amount of time staring at my computer. Granted, I'm rarely looking at a blank desktop but I like to have something tasteful and artistic when I want to access something on my desktop with my Win+D key chord.

One day I was sitting by a business analyst while collaborating on a project and noticed his nice desktop image. He introduced me to VladStudio, a Russian artist who has been pumping out hundreds of beautiful designs. He even has a system tray application called Companion than can change your wallpaper based on a custom schedule or whenever you just decide you need a new look by just double-clicking the system tray icon.

He provides low-resolution images for free that are still gorgeous. But you can get lifetime access to high resolution images for under $30.00 US. The registration is worth it if only to help him to keep creating designs. I registered several months ago, and he has since added widescreen resolutions images that look even better on my big wide Gateway.

The best part is the the images are very tasteful. I never have to worry about walking away from my workstation and returning to find an email from the HR department. Now I have people asking me where I got my nice desktop image. :-)

Submit this story to DotNetKicks

JavaScript String.format() method.

A while back I worked on a pretty heavy duty JavaScript interface that required, as is typical in any UI, a lot of string manipulation. I became tired of building strings with concatenation, they had a tendency to get unwieldy. I wrote this simple string formatting utility for building strings similiar to C#.

The best way to use it is to put it into an external JavaScript source file and reference it throughout the project.

Although the method has only one defined argument it will accept any number of arguments. If you provide more or less arguments than you define in your string they will not cause an error, they will be ignored.

String.format = function( text )

{

    //check if there are two arguments in the arguments list

    if ( arguments.length <= 1 )

    {

        //if there are not 2 or more arguments there's nothing to replace

        //just return the original text

        return text;

    }

    //decrement to move to the second argument in the array

    var tokenCount = arguments.length - 2;

    for( var token = 0; token <= tokenCount; token++ )

    {

        //iterate through the tokens and replace their placeholders from the original text in order

        text = text.replace( new RegExp( "\\{" + token + "\\}", "gi" ),

                                                arguments[ token + 1 ] );

    }

    return text;

};



You can test the method with these simple tests.

//simple tests

document.write( String.format( "no tokens<br />" ) );

document.write( String.format( "one token, no args ({0})<br />" ) );

document.write( String.format( "one token, one args ({0})<br />", "arg1" ) );

document.write( String.format( "one tokens, two args ({0})<br />", "arg1", "arg2" ) );

document.write( String.format( "two tokens, two args ({0},{1})<br />", "arg1", "arg2" ) );

document.write( String.format( "two tokens swapped, two args ({1},{0})<br />", "arg1", "arg2" ) );

document.write( String.format( "four tokens interwoven, two args ({0},{1},{0},{1})<br />", "arg1", "arg2" ) );

Submit this story to DotNetKicks

Free Image: Old Timey Register

From Creative Commons

Submit this story to DotNetKicks

Free Image: Old Wheel by a Tree

From Creative Commons

Submit this story to DotNetKicks

Free Image: Golden Gate Goes By

From Creative Commons

Submit this story to DotNetKicks

Free Image: Windmill Overhead

From Creative Commons

Submit this story to DotNetKicks

Free Image: Tilted Windmill

From Creative Commons

Submit this story to DotNetKicks

Free Image: Windwill at Dusk

From Creative Commons

Submit this story to DotNetKicks

Free Image: Sunset Over the Waves

From Creative Commons

Submit this story to DotNetKicks

Free Image: Waves

From Creative Commons

Submit this story to DotNetKicks

Free Image: Bird Over the Waves

From Creative Commons

Submit this story to DotNetKicks

Free Image: Bird on the Sand

From Creative Commons

Submit this story to DotNetKicks

Free Image: Light on the Waves

From Creative Commons

Submit this story to DotNetKicks

Free Image: Bird Tracks in the Sand

From Creative Commons

Submit this story to DotNetKicks

Free Image: Shadows

From Creative Commons

Submit this story to DotNetKicks

Free Image: Mushrooms

From Creative Commons

Submit this story to DotNetKicks

Free Image: Flower

From Creative Commons

Submit this story to DotNetKicks

Free Image: Duck

From Creative Commons

Submit this story to DotNetKicks

PD Photo -- Free Photos And Pictures

Finding images to use in your site is a real pain if you care anything about the photographer's copyright. While looking for a nice picture of a frog I found some sites charging hundreds of dollars for a single image. While I understand that a photographer can spend thousands of dollars on photographic equipment, and they need to eat too, that pricing is way too high for my budget.

Fortunately, there's a great site, PD Photo.org that is a repository of public domain and royalty free images that you can manipulate and use for pretty much anything you want. The only thing they ask is that you verify the license of the photo before you use it, as some of their photo's do have restrictions (which they explain in their FAQ) and to provide a link back to them acknowledging where you found the image.

Well, I found a couple images that I like and am already using one for the header of this blog. Visit their site and check them out.

Submit this story to DotNetKicks

Thursday, April 26, 2007

Night Owl Gene Discovered (Maybe)

The British newspaper Telegraph reports that there may be an "after-hours gene". Basically this gene causes people to fall out of sync with the normal circadian cycle of being alert and awake during light hours and sleeping during darkness.

My wife and I have been night owls our entire lives. I've tried to fight it for years, but within 24 hours of not having to wake at a certain time for work I will lapse into going into a delayed sleeping pattern. And it's not long hours of sleep either, I go to sleep between 2-3 AM and naturally wake around 11 AM. Which puts me around 8-9 hours of sleep. I don't need an alarm clock and my activity level has very little effect. It's been that way for my entire life even during my youth or when I was extremely active and very fit. It's not caused by age or my current, fairly sedentary, lifestyle. My wife is the same, we're just a few hours out of sync I guess. Out of step with the world.

I don't know if I want to be labeled a 'night owl' though, maybe a 'night frog'?

Submit this story to DotNetKicks

.NET Literals Are Implicit Instances.

In .NET literals are really just instances without a name.

Many developers will add extra fields to their code when they simply want to perform an operation on a simple string or numeric literal. This is unnecessary because .NET exposes the same methods from a literal as from an explicit instance field. In .NET literals are implicitly treated as instances.

Arguments about factoring and embedding strings and values in your code aside, this is more about what you *can* do than what the proper way to manage literals is.

When working with a string or numeric literal you don't need to create a new instance field to perform operations on the value. You can call the methods directly because the literal *is* an instance. You can call any non-static method that is exposed by the implicit type of the literal.

For example, you need to compare an unknown value against a constant value that doesn't change. The method could be written as:

/// <summary>

/// Contrived Literals Example 1

/// </summary>

/// <param name="value"></param>

/// <returns></returns>

public bool IsContrivedExample1( int value )

{

    int importantNumber = 1;

    int comparison = importantNumber.CompareTo( value );

    bool result;

    if ( comparison == 0 )

    {

        result = true;

    }

    else

    {

        result = false;

    }

    return result;

}



Some might look at that and not see a problem, and logically, there is no real problem. If it's a method that doesn't get called very often the additional field creation and assignments operations don't matter. The fields are well-named and their roles are clear. But this is an extremely contrived example. Most applications code-bases are generally made up of hundred's or thousands of lines of code, thereby making brevity of code your friend.

Here's an example of using the numeric literal directly to perform the same operations.

/// <summary>

/// Contrived Literals Example 2

/// </summary>

/// <param name="value"></param>

/// <returns></returns>

public bool IsContrivedExample2( int value )

{

    return ( 1.CompareTo( value ) == 0 );

}



We were able to reduce the code by 7 lines (not including braces). Not much in this case, but let's say you have 700 lines of methods like this, you drop about 600 lines of code! Not to mention 3 field creation and 3 assignment operations per method.

Now let's take a look at the resultant IL to see what .NET thinks of the differences in code structure.


.method public hidebysig instance bool IsContrivedExample1(int32 'value') cil managed
{
// Code size 41 (0x29)
.maxstack 2
.locals init ([0] int32 importantNumber,
[1] int32 comparison,
[2] bool result,
[3] bool CS$1$0000,
[4] bool CS$4$0001)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.0
IL_0003: ldloca.s importantNumber
IL_0005: ldarg.1
IL_0006: call instance int32 [mscorlib]System.Int32::CompareTo(int32)
IL_000b: stloc.1
IL_000c: ldloc.1
IL_000d: ldc.i4.0
IL_000e: ceq
IL_0010: ldc.i4.0
IL_0011: ceq
IL_0013: stloc.s CS$4$0001
IL_0015: ldloc.s CS$4$0001
IL_0017: brtrue.s IL_001f
IL_0019: nop
IL_001a: ldc.i4.1
IL_001b: stloc.2
IL_001c: nop
IL_001d: br.s IL_0023
IL_001f: nop
IL_0020: ldc.i4.0
IL_0021: stloc.2
IL_0022: nop
IL_0023: ldloc.2
IL_0024: stloc.3
IL_0025: br.s IL_0027
IL_0027: ldloc.3
IL_0028: ret
} // end of method LiteralsTest::IsContrivedExample1



.method public hidebysig instance bool IsContrivedExample2(int32 'value') cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init ([0] bool CS$1$0000,
[1] int32 CS$0$0001)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.1
IL_0003: ldloca.s CS$0$0001
IL_0005: ldarg.1
IL_0006: call instance int32 [mscorlib]System.Int32::CompareTo(int32)
IL_000b: ldc.i4.0
IL_000c: ceq
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method LiteralsTest::IsContrivedExample2


The second example definitely has less overhead. There are less fields being created and loaded and less logical operations.

Let's see what the IL looks like if we replace the integer literal with a constant integer that is declared in the containing class.


.method public hidebysig instance bool IsContrivedExample3(int32 'value') cil managed
{
// Code size 19 (0x13)
.maxstack 2
.locals init ([0] bool CS$1$0000,
[1] int32 CS$0$0001)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.1
IL_0003: ldloca.s CS$0$0001
IL_0005: ldarg.1
IL_0006: call instance int32 [mscorlib]System.Int32::CompareTo(int32)
IL_000b: ldc.i4.0
IL_000c: ceq
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method LiteralsTest::IsContrivedExample3


Hmm, aside from the method name, the IL is exactly identical. It appears that there is no penalty for embedding a literal in our method nor is there a benefit for using a constant.

I used to be a steadfast believer in placing *all* my literals in constant fields. Unless the field needs to be reused elsewhere, keeping literals with the methods that utilize them, along with judicious commenting, will keep my code-base cleaner and easier to manage.

Using literals in your code is up to your discretion and coding standards. I hope that you were able to use this article to expand your .NET coding repertoire.

Below is a class containing several examples of calling instance methods directly against string and integer literals.

public class LiteralsTest

{

    private const int ContrivedValue = 1;

 

    /// <summary>

    /// Contrived Literals Example 1

    /// </summary>

    /// <param name="value"></param>

    /// <returns></returns>

    public bool IsContrivedExample1( int value )

    {

        int importantNumber = 1;

        int comparison = importantNumber.CompareTo( value );

        bool result;

        if ( comparison == 0 )

        {

            result = true;

        }

        else

        {

            result = false;

        }

        return result;

    }

 

    /// <summary>

    /// Contrived Literals Example 2

    /// </summary>

    /// <param name="value"></param>

    /// <returns></returns>

    public bool IsContrivedExample2( int value )

    {

        return ( 1.CompareTo( value ) == 0 );

    }

 

    /// <summary>

    /// Contrived Literals Example 3

    /// </summary>

    /// <param name="value"></param>

    /// <returns></returns>

    public bool IsContrivedExample3( int value )

    {

        return ( ContrivedValue.CompareTo( value ) == 0 );

    }

 

    /// <summary>

    /// Tests the string literals.

    /// </summary>

    public void TestStringLiterals()

    {

        System.Console.Out.WriteLine( "Testing String Literals" );

        System.Console.Out.WriteLine( "fizz".CompareTo( "buzz" ) );

        System.Console.Out.WriteLine( "fizz".CompareTo( "fizz" ) );

        System.Console.Out.WriteLine( "buzz".CompareTo( "fizz" ) );

        System.Console.Out.WriteLine( "TypeCode: {0}", "fizz".GetTypeCode() );

        System.Console.Out.WriteLine( "Type: {0}", "fizz".GetType() );

        System.Console.Out.WriteLine( "HashCode: {0}", "fizz".GetHashCode() );

        System.Console.Out.WriteLine( "fizz".Equals( "buzz" ) );

        System.Console.Out.WriteLine( "fizz".Equals( "fizz" ) );

        System.Console.Out.WriteLine( "buzz".Equals( "fizz" ) );

        System.Console.Out.WriteLine( "fizz".Length );

        System.Console.Out.WriteLine( "Character at index 0: {0}", "fizz"[ 0 ] ); //wha, wha, what? ;-)

        System.Console.Out.WriteLine( "Clone(): {0}", "fizz".Clone() );

        System.Console.Out.WriteLine( "Contains(\"iz\"): {0}", "fizz".Contains( "iz" ) );

        // We are replacing the "working" variable with the string literal value.

        // It's a bit of a contrived example, but the method works.

        char[] working = new char[] {'b', 'u', 'z', 'z'};

        "fizz".CopyTo( 0, working, 0, 4 );

        System.Console.Out.WriteLine( working );

    }

 

    /// <summary>

    /// Tests the integer literals.

    /// </summary>

    public void TestIntegerLiterals()

    {

        System.Console.Out.WriteLine( "Testing Integer Literals" );

        System.Console.Out.WriteLine( 1.CompareTo( 0 ) );

        System.Console.Out.WriteLine( 1.CompareTo( 1 ) );

        System.Console.Out.WriteLine( 0.CompareTo( 1 ) );

        // Cannot implicitly convert type 'int' to 'string'.

        string x = 1.ToString();

        System.Console.Out.WriteLine( "ToString(): {0}", x );

        System.Console.Out.WriteLine( "TypeCode: {0}", 1.GetTypeCode() );

        System.Console.Out.WriteLine( "Type: {0}", 1.GetType() );

        System.Console.Out.WriteLine( "HashCode: {0}", 1.GetHashCode() );

        System.Console.Out.WriteLine( 1.Equals( 0 ) );

        System.Console.Out.WriteLine( 1.Equals( 1 ) );

        System.Console.Out.WriteLine( 0.Equals( 1 ) );

    }

 

    /// <summary>

    /// Runs the tests.

    /// </summary>

    public void RunTests()

    {

        TestStringLiterals();

        System.Console.Out.WriteLine();

        TestIntegerLiterals();

    }

}

Submit this story to DotNetKicks