Brian Hartsock's Blog

Archive for January, 2009

Code Wars

by bhartsock on Jan.20, 2009, under Uncategorized

You know software development is mainstream when you hear an argument about programming languages at a bar.

“Dude, I program in C, it is way more pure than Java”

“Whatever, you probably have memory leaks everywhere”

“At least I know what memory management is, tool”

I am not joking, I heard something similar tonight. Obviously I embellished a tiny bit, but I would never have expected to hear an argument like that in a bar from a group that I am not a part of.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

1 Comment : more...

The Smell of Assertionless Tests

by bhartsock on Jan.18, 2009, under Uncategorized

Today I found myself at a crossroads regarding testing. In my efforts to have pure unit tests, I had created tests with no assertions. Each test contained a mock object that verified multiple expectations, but no assertions. While each mock expectation could be thought of as an assertion, is it really a good idea to test the algorithm?

I say no.

The algorithm shouldn’t matter. The only thing that should matter is the input and output of each function.

Now I found my tests are much more stable and not nearly as much of a pain to write. I am setting up my expectations for input and output, but not regarding how to get there.

As you might expect though, the tests aren’t isolated to one class. They cross a few class boundaries, but not layer boundaries.

Have I traded one evil for another? I honestly don’t know, but I am going with my gut, and what makes sense. Having no assertions isn’t right in my opinion. What do you think?

Post to Twitter Post to Digg Post to Facebook Post to Reddit

2 Comments :, more...

The On Demand Revolution Continues – PlayOn

by bhartsock on Jan.18, 2009, under Uncategorized

A few weeks ago, a co-worker showed me PlayOn. Installing it at home was more important than dinner that night. Luckily it only took about 5 minutes to get it working and I was able to eat pizza while watching the On Demand Tube.

PlayOn is a simple UPNP server you install on any Windows computer in your home. Most game consoles, like my Xbox360, see the media server on the network and allow you browse all of PlayOn’s content.

What content you might ask? Hulu, CBS, Netflix, ESPN, and YouTube. Wow.

Bringing the content of the web directly to the living room is yet another step towards a completely on demand world. Paying for 100 channels I don’t watch so that I can get the 10 I do makes no sense to me. Why can’t I just pay for what I want? And why can’t I watch what I want whenever I want?

If you have an Xbox 360, Wii, or PS3, you should go try PlayOn today.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

1 Comment :, more...

Pie me

by bhartsock on Jan.17, 2009, under Uncategorized

n6229367_40560340_7782

Raising money for Relay for Life by selling tickets to pie managers was a great, and gross idea. I am still a little worried I have cool whip in my ear.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

2 Comments more...

Using NHaml, from Source

by bhartsock on Jan.15, 2009, under Uncategorized

The NHaml project is a super simple view engine that can be used with ASP.NET MVC. Unfortunately, like many young projects, it has changed so much in recent months, many articles on it are out of date. In fact, I don’t think I have seen any setup guides that still actually work. So, here is how to setup NHaml on SVN revision 98.

Couple of prerequisites before you get started. I am assuming you have TortoiseSVN and ASP.NET MVC

Here is the section outline so you can jump a head if you already have some of the steps done.

Start a new project

Open Visual Studio 2008, and create a new project. Obviously, you can name this project however you wish but throughout this article, I will be referring to the project as NhamlSetupApp.
1-15-2009-3-45-23-pm-0025

Select an ASP.NET MVC Web Application and enter in your project name.
1-15-2009-4-06-19-pm-0016

Downloading and Compiling NHaml

Using ToroiseSVN, we can checkout an up-to-date copy of the source code of NHaml. Just right click in the folder you wish you checkout the source and click SVN Checkout
1-15-2009-3-50-53-pm-0024

This brings up the checkout screen which allows you to enter a repository URL. Currently, the NHaml trunk can be found at http://nhaml.googlecode.com/svn/trunk. Check out the code, and load the solution file found at /nhaml/src/NHaml.sln.
1-15-2009-3-52-36-pm-0023

After getting the solution open, we need to make sure the build is set to release through Configuration Manager. Go to Build -> Configuration Manager and select Release.

1-15-2009-3-58-49-pm-0021

Now build…
1-15-2009-3-59-02-pm-0020

After the solution has been built, you can navigate to the /nhaml/src/NHaml.Web.Mvc/bin/Release and find all the binaries you need in your project. We can copy these binaries into a directory in the NhamlSetupApp and add them as references.

First copy from /nhaml/src/NHaml.Web.Mvc/bin/Release
1-15-2009-4-02-53-pm-0019

Create a directory called lib in /NhamlSetupApp/ and copy all the NHaml binaries there.
1-15-2009-4-03-35-pm-0018

Add NHaml References to NhamlSetupApp

Right-click on References and click on Add Reference.
1-15-2009-4-07-24-pm-0015

Once the dialog opens, go to the Browse tab, and navigate to /NhamlSetupApp/lib that you created earlier. From there select Microsoft.Web.Mvc, NHaml, NHaml.Web.Mvc and Open.
1-15-2009-4-24-44-pm-0010

Modify the project to run NHaml views

First, you need to edit Global.asax and add the NHaml view engine to the collection of view engines. Adding the following lines to the Application_Start function can easily accomplish that.

ViewEngines.Engines.Add(new NHaml.Web.Mvc.NHamlMvcViewEngine());

1-15-2009-4-09-55-pm-0012

Next, web.config needs to be modified so that the NHaml view engine can create the views and reference the appropriate assemblies.

Add the following section definition in configSection

<section name="nhaml" type="NHaml.Configuration.NHamlConfigurationSection, NHaml"/>

Now the NHaml configuration element can be defined.

<nhaml autoRecompile="true" templateCompiler="CSharp3" encodeHtml="false" useTabs="false" indentSize="2">
  <assemblies>
    <add assembly="NhamlSetupApp"/>
  </assemblies>
  <namespaces>
    <add namespace="NhamlSetupApp"/>
    <add namespace="NhamlSetupApp.Controllers"/>
  </namespaces>
</nhaml>

1-15-2009-4-34-33-pm-0009

Add some Haml

For this project, the next step I am going to take is creating an application.haml file as the equivalent of a Site.master. In the shared folder, just add a new item that is a text file named application.haml.

1-15-2009-4-43-13-pm-0008

1-15-2009-4-43-31-pm-0007

Now insert some NHaml markup.
1-15-2009-4-43-43-pm-0006

Next I am going to add a new view in Home called test.haml.

1-15-2009-4-44-02-pm-0005

1-15-2009-4-19-11-pm-0011

1-15-2009-4-45-20-pm-0004

Now just add a stub method in the view.
1-15-2009-5-04-24-pm-0000

Run and enjoy

1-15-2009-4-46-28-pm-0003

Hope this helps someone. The first time you set it up can be very troublesome.

Post to Twitter Post to Digg Post to Facebook Post to Reddit

5 Comments :, , , , more...

Post by day

January 2009
M T W T F S S
« Dec   Feb »
 1234
567891011
12131415161718
19202122232425
262728293031