January 2005 - Posts

CodeBetter.com Blogs, check em out!

Darrell, Brendan, Grant, and Paul have all moved their blogs over to their new site, codebetter.com.  I’ve subscribed to their main feed, you should too.  Oh and checkout their new skin, schweet!

Values for successful software development projects

A little while back I mentioned I was going to be writing an article about Agile Software Development for business “people”.  The article ended up having a slightly different focus as I thought it made selling the ideas of agile software development a little less techie.  Anyway the results can be found at:

Is your next project likely to succeed?
Values for successful software development projects.

You even get a picture of me if you click through!  I’d love some comments if anyone has any.  Feel free to email me at steve dot eichert at gmail dot com or via the contact form on my blog.

Sam mentions a dynasty, he just has the wrong team....

Sam Gentile mentions that the Patriots may be a dynasty, I’m afraid that “dynasty” is about to be destroyed by the Eagles.  Although they’ve struggled to get past the NFC Championship game the last 3 year, they have finally broken through and will win their first of many Super Bowl trophies in 2 short weeks.  Sam, you’ve enjoyed a long run at the top,  you should be proud for having the second best team in the NFL!  Go Eagles!

TDD with DDD

I recently started development on a. NET project that will be making hearty (I meant to say heavy, but I think I like hearty better :-) ) use of test driven development (TDD) and domain driven design (DDD). I've noticed a couple things over the fist few weeks of development that I wanted to make note of.  This entry will focus on how separating data operations into repositories improves the testing experience.

The first thing I've noticed is that following the design "guidelines" within DDD, specifically in regards to encapsulating data retrieval and persistence within repositories, makes writing unit test for database related activities much smoother. In previous projects rather then separating all data access in repositories I had methods on my domain objects, such as FindAll(), FindOne(), and .Save(). Since each domain object provided the interface for performing the data operations I ended having test classes for each domain object that did the testing of these data operations. Since many of the classes had dependencies (fk relationships) with other classes in the domain the tests for my domain objects required a lot of setup. My test classes ended up using domain objects that the domain object I was testing were dependent on. By separating all data operations into a repository, my test class can handle setting up all data necessary. Since this all occurs in a single test class it reduces the duplicated logic that previously appeared in a bunch of the test classes for the individual domain objects. Overall it's made the process much smoother and has led to cleaner test code, and more importantly cleaner code within my domain model.

Toshiba M200 Tablet....first thoughts

I broke down and purchased myself a Toshiba M200 Portege as a late Christmas present to myself.  My main development machine had been giving me serious trouble lately so I was shopping around for a replacement.  I’ve wanted to pick up a Tablet for a while but had resisted the urge since it wasn’t “time” for another computer.  So at the end of December I decided to head on over to Toshiba Direct and place my order.  As a side note I think I’d go through CDW rather then Toshiba Direct.  It took much longer for my order to be fulfilled as it was coming from there facilities in China.  CDW offers a bunch of different pre-built models so there really isn’t much benefit from going with Toshiba Direct unless you happen to get to them when their running a good deal.

My M200 will be my main development machine, replacing my Dell Inspiron 8600.  I got my M200 pretty loaded up (2ghz CPU and 1.5 G RAM) for that reason.  I can say one thing for sure, it kicks my old machines’ ass as far as performance.  The one concern I had was the smaller 12.1” screen, as opposed to the 15” screen on my old laptop.  All I can say is I don’t even notice that I lost about 3”.  The display is very crisp, and I love the overall size of the laptop.  The only thing I need to get used to is the layout of the keyboard. 

I’ve been using my M200 primarily in notebook mode but have toyed around in Tablet mode a bit.  I still need to play around more to get comfortable with “inking”.  I’m hoping to do a little Tablet PC development, I just need a couple of my other side projects to be wrapped up.  As I explore more I’ll be sure to provide updates… :-)

TDD is faster?

Spread the word!

Hey, I'll do it for a cool $100 million

Checkout this article on CNN about how an FBI software project costing $170 MILLION DOLLARS may end up getting scrapped.  Anyone want to work with me on a re-write of the application for a cool $100 million?

Allerton brings Team Foundation to Linux, Solarix, and Mac OS

Eric Sink, CEO of SourceGear announced a new product code named “Allerton” that will bring Microsoft Team Foundation to Linux, Solaris, and Mac OS.  I hope they offer a nice single developer license free of charge like they do for Vault so I can access Team Foundation when I’m doing Mono development on my Mac!  It’d be really snazzy if it was written on Mono, however, my recent experiences with Gui development using Mono has me guessing they went in another direction.

ThoughtWorks is cool

Isn’t it?

Is it better to look big?

I recently came across “Marketing Software When You Are a Small Company” via…..um…well I forget but somebody out there.

In the article Scott talks about looking big when your small.  This is something I’ve thought about a good bit.  I have a website for my little consulting practice, and by “practice” I mean me.  I only do “consulting” part time as I do have a full time job that keeps me busy during “regular” business hours.  When I originally did the website for my consulting practice I ended up making it sound much bigger then it actually was.  I’m in the process of re-doing the site and have been trying to decide the best way to present things. 

I’m leaning towards trying to give visitors a true view into what my “practice” is all about.  That means revealing that it’s a practice of 1.  It means selling that as an advantage rather then a disadvantage.  It’s an interesting problem that I’m sure many Micro ISV’s run into.  I wonder who has found success in the marketing of a Micro ISV as what it is rather then what we often times think it needs to be to gain customers.

While on the subject, if anyone is looking for a .NET Consultant to help with projects “off-hours” I’d love the opportunity…just let me know!

The New Methodology

Martin Fowler’s “The New Methodology” talks about Agile, how it’s different from “predictive” methodologies, and how to decide if it’s right for you.  He talks specifically about lots of things that I’m going to reference in something I’m working on which is why this post is here :-)

 

Cocoa#

I have my eyes on what Geoff is doing with Mono & Cocoa.  I’ve played with Gtk# and Mono a little bit and would definitely love to see Cocoa# gain full support within Mono.  It looks like Geoff is getting close…

Can anyone recommend good Java bloggers?

Although I consider myself a .NET guy I like to try and keep up with what’s going on in the java world.  I recently subsribed to the www.javablogs.com feed for “Hot Entries” however the signal to noise and the pure volume of posts on that feed are too much for me.  Can anyone share who they believe to be A-list java bloggers?

Thanks!

.Text to DasBlog Conversion Tool Found!

Stefano Demiliani has done some legwork and has tracked down a .Text to dasBlog conversion tool.  The tool requires direct access to the .Text database server which I don’t have but it does have some code that shows how to use the dasblog web service which may be helpful.

Moving from TDD to PPD?

Dave talks about a new programming practice he temporarily calls "Ping Pong Development". It sounds like a good way to make pair programming a little more interesting and competitive. Once I get more people to use TDD at my gig maybe I'll introduce it. We'll have to get a scoreboard up somewhere so we can crown someone the TDD king.

Posted with MonoBlog

Posting from Mono Blog Client

I've been playing with Mono a little bit recently and been having fun messing around with coding in C# on my Mac. I was originally hoping I'd be able to get MonoDevelop running on my Mac but after spending more time then I should have I've officially given up on that. So now its Eclipse, with the C# syntax highlighting. Of course as I play around with Mono I need a way to post what I discover on my Mac, so why not write a Gtk# app on Mono to post to my blog. If this actually shows up on my blog I at least have a start. The UI is the ugliest thing you'd ever want to see but, hey, that can be cleaned up later!

Is it possible to change the Xml comment "macro" that runs when you type "///"?

Commenting code is a necessary evil on the code base I’m currently working on since we’re going to be generating documentation from the XML Comments in the code.  One of the “things” that I find myself doing often within my classes is moving the <summary/> comment onto a single line to reduce the amount of space taken up by comments.  So this:

/// <summary>
/// Initialize an instance of the <see cref="Property"/> class.
/// </summary>

becomes:

/// <summary>Initialize an instance of the <see cref="Property"/> class.</summary>

Does anyone know if it’s possible to change the default behavior or change the “template” that VS.NET uses?

.Text to dasBlog converstion tool

Does anyone know of a .Text to dasBlog conversion tool?  I’m thinking about creating another blog and I’d like to take a subset of the posts as well as their comments along with me.  It would certainly be nice if I could just run a nice little import utility that I point at my existing .Text blog which sucks everything into my new blog which will likely be running dasBlog.  A quick search turned up a couple dasBlog to .Text converters but nothing the other way. 

How do you become an independent consultant and get contracts?

I came across an interesting post about becoming an independent consultant and how to get contracts.  Lots of interesting things in the post most of which I've already heard.  I wonder how different the rates are for .NET Consultants these days.  The author mentions rates of $75-$200/hr for Java Developers in the Denver area.  Anyone in the Philly area open to sharing some information on what the going rate is for good .NET talent these days?

Is this the year of Python?

It seems Python is the language that everyone (sam, john, darrell, ...) has decided to learn this year.  Since I wouldn't want to be left out of the mix I figured I might as well spend some time kicking the tires of IronPython as well.  We'll see how it goes.

Code generation with CodeSmith + Reflection == goodness

Scott Hanselman blogs about the process his gig uses to generate all kinds of goodness via code generation with CodeSmith and Reflection.  I've been meaning to update the code my entity framework generates to use CodeSmith templates for a long long time, and now that I've actually played with CodeSmith and thus been hooked I think I'll have to put that on my list of things to try and accomplish in the near future.  Anyway, its a great post that gives a little look into how a large financial institution leverages the power of code generation and reflection to provide them with a set of "very robust" tests.  Good stuff!

Strategy for unit testing a web UI

As the loyal followers of my blog know, I'm a big test driven development (TDD) advocate.  I try and do all new development using TDD.  Sometimes I fall back into my old ways but a couple ugly classes, and a few bugs usually keep me in line.  The one area where I've been a little lax in my automated unit testing is in regards to the UI of my applications.  As expected I often see bugs cropping up within the UI of the applications I work on.  Since there aren't any unit tests to validate the UI I don't know about them until our QA analyst uncovers them, or even worse the customer.  I've recently been putting some thought into the best method for testing UI's, specifically of the web variety.  My current thoughts follow....

Often times when writing web based applications we wire up logic for persisting data entered into a web form within the Click event handler for the save button on the page.

protected void saveButton_Click(object sender, EventArgs e) {
   if(Page.IsValid) 
        // load values entered into web form into business object
        Customer c = new Customer();
        c.FirstName = firstName.Text;
        c.LastName = lastName.Text;
        ....

        new CustomerRepository.SaveCustomer(c);
   }
}

The problem with this approach is it's difficult to test the logic within the save button click event.  One of the methods I've thought about using to ease the testing of the logic involves creating an interface for the "view" that specifies all the data that is entered within the web form.

public interface ICustomerView {
   string FirstName { get; set; }
   string LastName { get; set; }
}

The second step, after the view is defined is to create a controller that loads, and reads the view.

public class CustomerController {
   public void LoadView(ICustomerView view, Customer customer) {
      view.FirstName = customer.FirstName;
      view.LastName = customer.LastName;
      // ... others
   }

   public void ReadView(ICustomerView view, Customer customer) {
     customer.FirstName = view.FirstName;
     customer.LastName = view.LastName;
      // ... others
   }
}

Now we have an interface as well as a controller that we can test using our usually unit testing methods.  Ideally we'd also write some tests to ensure that the web form that is implementing the ICustomerView interface properly loads and reads the controls that are on the form, however, with the current set of tools we have available I don't know of a way to handle that.  We can use NUnitAsp to test that the controls exist and that we can read the values, however, we can't do this through our controller class.  We also aren't able to ensure the base page class implements the necessary interface (ICustomerView).

Our web form utilizing the ICustomerView and Controller classes is below:

public

class CustomerEdit : System.Web.UI.Page, ICustomerView {
   protected TextBox firstName;
   protected TextBox lastName;
   protected Button saveButton;
   CustomerController controller = new CustomerController();
   CustomerRepository repository = new CustomerRepository();
   Customer customer = null;


   public int CustomerID {
      get { // read customer id from querystring, etc. }
   }

   #region

ICustomerView Members
   public string FirstName {
      get { return firstName.Text; }
      set { firstName.Text = value; }
   }

   public string LastName {
      get { return lastName.Text; }
      set { lastName.Text = value; }
   }
   #endregion

   private void Page_Load(object sender, System.EventArgs e) {
      if (!Page.IsPostBack) {
         customer = repository.GetCustomer(this.CustomerID);
         controller.LoadView(this, c);
      }
   }

   private void saveButton_Click(object sender, EventArgs e) {
      if (Page.IsValid) {
         customer = new Customer();
         controller.ReadView(this, customer);
         repository.SaveCustomer(customer);
      }
   }
}

The final step in the process is to verify that the view actually works.  To test this NUnitAsp can be used to set the values of the controls on the web form, and then "clicking" the save button.

[TestFixture]
public class CustomerViewTest : WebFormTestCase {
   public CustomerViewTest() {}

   TextBoxTester firstName;
   TextBoxTester lastName;
   ButtonTester saveButton;

   protected override void SetUp() {
      firstName = new TextBoxTester("firstName", CurrentWebForm);
      lastName = new TextBoxTester("lastName", CurrentWebForm);
      saveButton = new ButtonTester("saveButton", CurrentWebForm);
      Browser.GetPage(http://localhost/UITesting.Web/WebForm1.aspx);
   }

   [Test]
   public void ControlsAreVisible() {
      AssertVisibility(firstName, true);
      AssertVisibility(lastName, true);
      AssertVisibility(saveButton, true);
   }

   [Test]
   public void PressingSaveButtonWillSaveCustomer() {
      firstName.Text = "Steve";
      lastName.Text = "Eichert";
      saveButton.Click();
      
     
CustomerCollection customers = new CustomerRepository().FindAll();
      AssertEquals(1, customers.Count);
      Customer c = customers[0];
      AssertEquals(firstName.Text, c.FirstName);
      AssertEquals(lastName.Text, c.LastName);
   }
}

Note: I couldn't actually get my tests to run within NUnit so they might not work.  I keep getting a FileNotFoundException when trying which was a bit of a bummer.  Does anyone have NUnitAsp running on NUnit 2.2? 

What strategy do you use to run automated unit tests for your UI?