January 2007 - Posts

Updating RSS feed to use Feedburner

I've finally signed up for FeedBurner.  My feed address is:

http://feeds.feedburner.com/SteveEichert/

I'll be updating this site to issue a redirect to the new feed shortly but if you don't want to wait feel free to switch to the new feed now

I should also mention that the new feed is going to be pulling content from a "new" blog that I've setup at http://iqueryable.com/.  I've had some issues lately with my hosting provider that has prevented me from updating my site, plus as you can tell by the silence on this blog of late I needed a change.  I haven't decided if I'm going to migrate the content on this blog over to the new blog. 

Demotivate your programming team in 10 easy steps!

Manuel Klimek has  put an excellent list together for those looking to regain control of their team by demotivating each and every member. Checkout his Top 10 ways to demotivate your programming team to get started.  Oh and while your at it you might as well see what you can do to build the Anti-Team (and don't forget these team members). 

Crappy software is within your reach, go get it!

API Based XML Streaming & Functional OO Programming

Ralf Lämmel, who is the man behind LINQ to XSD, has a couple of new papers on his site that I have not seen up until now. The first paper is on Function OO Programming and the second is on XML Steaming. I've only skimmed each but they're bound to be interesting to anyone interested in functional programming, streaming XML API's, and LINQ.


API-based XML streaming with FLWOR power and functional updates
Functional OO Programming with Triangular Circles

You can also find a bunch of other interesting papers on Ralf's website at: http://homepages.cwi.nl/~ralf/

Converting a CSV file to XML using LINQ to XML and Functional Construction

In this post we aim to transform a text file into a hierarchical XML document.  As shown in Listing 12.11, the text file will contain the following book information: the ISBN, Title, Author(s), Publisher, Publication Date, and Price.

Listing 12.11    CSV of Books

0735621632,CLR via C#,Jeffrey Richter,Microsoft Press,02-22-2006,59.99
0321127420,Patterns Of Enterprise Application Architecture,Martin Fowler,Addison-Wesley Professional,11-05-2002,54.99
0321200683,Enterprise Integration Patterns,Gregor Hohpe,Addison-Wesley 04 Professional,10-10-2003,54.99
0321125215,Domain-Driven Design,Eric Evans,Addison-Wesley Professional,08-22-2003,54.99
1932394613,Ajax In Action,Dave Krane;Eric Pascarello;Darren James,Manning Publications,10-01-2005,44.95

Our goal is to parse the data in the text file and produce a hierarchy of XML as shown below:

Listing 12.12    XML Output

<?xml version="1.0" encoding="utf-8" ?>
<books>
  <book>
    <title>CLR via C#</title>
    <authors>
      <author>
        <firstName>Jeffrey</firstName>
        <lastName>Richter</lastName>
      </author>
    </authors>
    <publisher>Microsoft Press</publisher>
    <publicationDate>02-22-2006</publicationDate>
    <price>59.99</price>
    <isbn>0735621632</isbn>
  </book>
  <book>
    <title>Patterns Of Enterprise Application Architecture</title>
    <authors>
      <author>
        <firstName>Martin</firstName>
        <lastName>Fowler</lastName>
      </author>
    </authors>
    <publisher>Addison-Wesley Professional</publisher>
    <publicationDate>11-05-2002</publicationDate>
    <price>54.99</price>
    <isbn>0321127420</isbn>
  </book>
  …
</books>

The XML is constructed in a bottom up manner with functional construction, and query expressions that select the relevant data out of the individual lines of the file are intertwined to produce the desired XML.

In order to create our desired XML we’ll need to open the text file, split each line in the file into an array, and place each item in the array into the appropriate XML element.  Let’s start with opening the file and splitting it into parts.

from line in File.ReadAllLines("books.txt")
let items = line.Split(',')
// add functional construction statements for creating the XML

We leverage the static ReadAllLines method available on the File class to read each line within the text file.  Since ReadAllLines returns a string array we can safely use it in our from clause.  To split each line we make use of the Split method available on string, as well as the let clause that is available in C#.  The let clause allows us to perform the split operation once and refer to the result in subsequent expressions.  Once we have our line split apart we can wrap each item into the appropriate XML element.  

var booksXml = new XElement("books",
  from line in File.ReadAllLines("books.txt")
  let items = line.Split(',')
  select new XElement("book",
    new XElement("title", items[1]),
    new XElement("publisher", items[3]),
    new XElement("publicationDate", items[4]),
    new XElement("price", items[5]),
    new XElement("isbn", items[0])
  );

We conveniently left the authors out of the above query since they require a little extra work.  Unlike the other fields in our text file, there can be more than one author specified for a single book.  If we go back and review the sample text file, we see that the authors are delimited by a semicolon (“;”).  

    Dave Krane;Eric Pascarello;Darren James
 
As we did with the entire line, we can Split the string of authors into an array, with each author being an individual element in the array.  To be sure we get our fill of Split, we make use of it one final time to break the full author name into first and last name parts.  Finally, we place the statements for parsing out the authors into a query, and wrap the results of our many splits into the appropriate XML.


new XElement("authors",
  from authorFullName in items[2].Split(';')
  let authorNameParts = authorFullName.Split(' ')
  select new XElement("author",
    new XElement("firstName", authorNameParts[0]),
    new XElement("lastName", authorNameParts[1])
  )
)


When we add it all together we get the final solution, which can be seen in Listing 12.13.  

Listing 12.13    Final Implementation
using System;
using System.Query;
using System.Xml.XLinq;
using System.IO;

namespace LinqToXmlSamples.FlatFileToXml {
  class Program {
    static void Main(string[] args) {
      XElement xml =
        new XElement("books",
        from line in File.ReadAllLines("books.txt")
        where !line.StartsWith("#")
        let items = line.Split(',')
        select new XElement("book",
          new XElement("title", items[1]),
          new XElement("authors",
            from authorFullName in items[2].Split(';')
            let authorNameParts = authorFullName.Split(' ')
            select new XElement("author",
              new XElement("firstName", authorNameParts [0]),
              new XElement("lastName", authorNameParts [1])
            )
          ),
          new XElement("publisher", items[3]),
          new XElement("publicationDate", items[4]),
          new XElement("price", items[5]),
          new XElement("isbn", items[0])
        )
      );
      Console.WriteLine(xml);
    }
  }
}

As we’ve seen over and over again, Linq to XML allows us to mix and match data from varying data sources into functional construction statements.  The result is a very consistent programming API for developers, which makes the way XML is created from other data sources – whether they be relational, object, or a text file – consistent and predictable.

Tags: xlinq, linq to xml, linq

Dabble with your data with DabbleDB

In Google Reader this morning, I found an entry in the Programmable Web API feed for DabbleDB.  DabbleDB is a "Web 2.0" application that  combines "the best of group spreadsheets, custom databases, and intranet application into a new way to manage and share your information on the web."  I'm usually pretty skeptical of anything with the "Web 2.0" moniker, however, I'm very interested in new and better ways to present, manage, and integrate data.  In addition to providing a very compelling interface for building "applications" through the browser, DabbleDB also provides a Plugin API that allows you to create new "derived fields" by calling out to external HTTP-accessible applications (perhaps we could call these services?).

For a good overview of the functionality offered by DabbleDB checkout this "whirlwind demo", that won Best in Show at Under the Radar: Why Web 2.0 Matters".  When you're done there you can find out more on the explore page.

While I don't think I could have built it nearly as well as the DabbleDB folks have, what they've built is very similar to what I had in mind for the "ideal" platform for building out our data extensibility platform.  While our core schema is locked down, we do want our customers to be able to extend our application and their data to fit their specific needs.  In order to do this, I'd really like to provide our clients with a nice UI for defining the structure of their "extension data" in a way that is as intuitive as what you can see in the DabbleDB videos.  Dabble's own extensibility for "derived fields" is also of interest.  They're allowing derived fields to be added to sets of data by linking to external services, which is very similar to some ideas we've had.  The obvious difference is that they've actually built it.

Anyway, this all reminds me of Alex's Data 2.0 idea.  I wonder how much of it will show up in the next release of Base4.NET?

 

Technorati tags: , , ,

Selling a Canon 28-135mm IS USM

I recently upgraded my camera setup and found myself with a very good lens which I will rarely use.   Rather than hang onto it I've decided to try and unload it. 

The lens has gotten very good reviews on Amazon, as well as on a couple third party sites.  To see the details of the lens you can checkout the Amazon.com page for the lens.

If you have a Canon Digital SLR (Digital Rebel, XT, XTI, 20D, 30D, or 5D) and are looking to get a mid level zoom, drop me a comment or email with an offer.

email: steve dot eichert at gmail dot com

Apparently I'm "it", 5 things you didn't know about me

This wonderful game of blog tag has found it's way to me, thanks Sam!  So here goes 5 things you most likely didn't know about me.

  1. In college, my worst grade received was in Music History.  My only "C".  The class was in a huge auditorium, and did an amazing job of putting one to sleep.
  2. I've had the pleasure of being called both a "dumb jock" and a "nerd".  I was a typical "jock" in high school playing all three sports (Football, Basketball, Baseball) and I played running back in college at Bloomsburg University.  Now that I'm a "software guy" I get the "geek" and "nerd" tag often from family and friends.  A true distinction.
  3. I took more classes in college that used COBOL as the primary language, then any C based language (C, Java, C++).  I assure you it wasn't by choice. 
  4. I'm writing a book on LINQ with Fabrice.  It's going to kick major ass!
  5. I'm married with 2 kids, and have one on the way.  My wife and I have know each other (and pseudo dated) since I was in 6th grade.  Somehow she manages to still love me after all these years, at least that's what she tells me   A bonus thing that you might not know is that my son, Steven John Eichert Jr. (who is 3) has Down Syndrome.  Those who have been reading my blog for a while might already know this since I've talked about going to the Buddy Walk and such in the past.  It's not something I ever expected to be faced with, but it's been an amazing blessing and has affected my life in more positive ways then I could have ever imagined when I found out 3.5 years ago.

So that's it.  Now I need to find 5 people who haven't already been tagged.  Let's try...Darrell Norton, Dave Burke, Tim Haines, Eric White, and Fabrice.

Ruby on Rails Style Migrations for .NET

A while ago, amid my fascination with Rails, I did some investigation of the migrations support that Rails provides.  To this day my Ruby on Rails Migrations Explained post is by far the most visited page on my site.  I always find it interesting that despite my blog being almost entirely on .NET related topics, one of the few Ruby on Rails posts I've written is the most popular.

Anyway, when I originally investigated Rails I thought it was a great solution for handling the evolution of a database.  In fact, I believed in it enough to do some prototype work with it at work to try and get it to support everything we needed it to for the databases that we support (Oracle + SQL Server).  In the end we ended up not going with Rails for a variety of reasons.  To this day I still regret the decision as we're hand rolling scripts for each of our databases and not especially enjoying it.  All of this is why I was very interested to come across this post on Database migrations for .NET.  Unfortunately it doesn't yet support Oracle, and probably would need some tweaking to work in our environment.  Regardless, I'll certainly be having a look at it as a potential solution to the problems that we face for evolving our database schema. 

Database migrations for .NET is provided as part of the Castle Project Generator project.  You can find more information about it on the Generator Wiki page.

Technorati tags: , , ,

Parallels destroys my BootCamp setup

I’ve been happily running Windows XP on my MacBook Pro for at least 6 months, however, I recently got greedy and went searching for a solution that provided better integration and less rebooting.  Since there’s been a lot of talk surrounding Parallels, I decided to give them a try.  Since they provide a nice virtualization package that supports XP, plus they support having an image based off of BootCamp, and have Coherence as well (which makes it feel like you can run XP apps within OS X) it was a win win situation.  Or so I thought.

Apparently something within Parallels ends up hosing BootCamp.  I can no longer boot into BootCamp natively because it doesn’t recognize my mouse or keyboard (I tried both USB as well as the one’s on my MacBook Pro).  There are a TON of forum posts on the subject and so far absolutely no response from Parallels.  A couple individuals in the forums are ranting and raving about the fact that its beta and that's what you get but I think that’s bogus.  At least have someone from Parallels come out and say something.  Say…”Hey our latest build hoses your Native BootCamp image, here’s what we plan to do about it.  Here’s when we expect to have a fix, and if you’re brave this is what you can try to manually fix it.”  Don’t sit there silent while hundreds of customers and/or potential customers are going bonkers trying to figure out how to get their BootCamp setup working again outside of Parallels.

This is one of many bad experiences I’ve had since trying Parallels.  The performance has been more or less unusable, the setup and configuration of my images never seems to stick, and now it’s completely screwed up my BootCamp setup which had been working flawlessly for 6+ months.  And on top of it all they’re silent.  Come on folks, say something, your silence is losing you customers.

tags: , , ,