Friday, February 13, 2009

Source Control Follow up

It’s been about 3 1/2 months since I made the switch to Source Gear Vault as my primary home source control. In the time that I’ve been using it it has performed superbly.  I recently did an upgrade, simple, quick and painless. All totaled it took probably ten minutes to upgrade the server using a single setup executable. Contrast that to the day it took a co-worker to upgrade subversion and the fact that he had to compile the  new server GUI functionality and it quickly becomes apparent that subversion is more of a road block than an asset.

A couple of weeks ago I ran across this Source Control How To by Eric Sink, one of the Source Gear Co-Founders. Even if you’re a source control expert it’s a good read.

Sunday, February 8, 2009

LINQ to DataSets

There are tons of LINQ 2 SQL and LINQ to object examples out there but not many LINQ 2 DataSet examples. Here is a quick sample that creates a table, adds three rows and queries the rows.

The key parts of the query are casting the table as enumerable using the AsEnumerable() extension and the generic Field<T>() method.

 

   1: static void Main(string[] args)
   2:       {
   3:           // create a table with three columns
   4:           DataTable table = new DataTable();
   5:           table.Columns.Add(new DataColumn("ID", typeof(System.Int32)));
   6:           table.Columns.Add(new DataColumn("ContactName", typeof(System.String)));
   7:           table.Columns.Add(new DataColumn("CompanyName", typeof(System.String)));
   8:  
   9:           // add three rows
  10:           DataRow row = table.NewRow();
  11:           row["ID"] = 1;
  12:           row["ContactName"] = "James Smith";
  13:           row["CompanyName"] = "Petes Hardware";
  14:           table.Rows.Add(row);
  15:  
  16:           DataRow row2 = table.NewRow();
  17:           row2["ID"] = 2;
  18:           row2["ContactName"] = "Jon Jones";
  19:           row2["CompanyName"] = "Rodgers Travel";
  20:           table.Rows.Add(row2);
  21:  
  22:           DataRow row3 = table.NewRow();
  23:           row3["ID"] = 3;
  24:           row3["ContactName"] = "Jeff Jones";
  25:           row3["CompanyName"] = "Rodgers Travel";
  26:           table.Rows.Add(row3);
  27:  
  28:           // create a data set, not needed but it's more common
  29:           DataSet dataSet = new DataSet();
  30:           // add the table
  31:           dataSet.Tables.Add(table);
  32:  
  33:           // get the jones brothers
  34:           var jones = (from r in dataSet.Tables[0].AsEnumerable()
  35:                        where r.Field<string>("ContactName").Contains("Jones")
  36:                        select r).ToList();
  37:  
  38:           // list the results
  39:           foreach (var item in jones)
  40:           {
  41:               Console.WriteLine(String.Format("Found {0} working for {1}",
  42:                   item.Field<string>("ContactName").ToString(),
  43:                   item.Field<string>("CompanyName").ToString()));
  44:           }
  45:  
  46:           Console.Read();
  47:       }
 

Tuesday, February 3, 2009

Podcasts

I recently purchased a new Zune, which I like very much. One of the things that I’ve found is that there are a number of great podcasts available on the Zune market place. I think all of them are free, at least I haven’t had to purchase. Here are a list of the programming or IT related ones I’ve liked and links to them on the web.

.Net Rocks (Carl Franklin)

Stackoverflow.com (Joel Splosky and Jeff Attwood)

Hanselminutes (Scott Hanselman)

Windows Weekly (Paul Thurrott)

These are all pretty good podcasts generally development or industry related. Check them out. If you have any programming related podcast favorites pass them along.

Saturday, January 24, 2009

Windows 7

I Installed windows 7 on my home dev box. So far the results have been good. Windows 7 has much better performance than Vista does. The memory foot print on my box is about 1/3 that of Vista.

I did have a couple of issues that you may want to look for, first the SM Bus Controller drivers were not installed. This was easy to fix by getting the drivers from Intel. Secondly the Performance score is a little out of touch. The overall score for my hard drive was 2.9, which was really low. The drive is a Hitachi, not a high end drive, but not a bad drive either. At any rate, I disabled write caching and reran the test. Disabling the caching resulted in a score of 5.9. Obviously some work to be done here, but it is a B1 product.

Overall my experience so far has been pretty good, if you get a chance take windows 7 for a test drive.

Thursday, November 27, 2008

Using the VB TextFieldParser in C#

Sometimes you run across some hidden gems in the framework. One of these is the TextFieldParser class in the Microsoft.VisualBasic namespace. The TextFieldParser allows you to read and parse delimited files by specifying the positions as an array or by specifying the delimiters.    I know that a lot of C# developers would cringe at the thought of referencing a library from that other language, but given the functionality and the fact that this method requires no RegEx or xslt makes it a great solution.

Here's a quick sample that parses a position delimited file:

   1: public void ParsePositionalFile(string path)


   2:         {


   3:           


   4:             using (TextFieldParser parser = new TextFieldParser(path))


   5:             {


   6:                 parser.TextFieldType = FieldType.FixedWidth;


   7:                 int[] fields = { 9, 18, 36, 2, 25, 1, 1, 1, 8 };


   8:                 parser.SetFieldWidths(fields);


   9:                 string[] currentRow = new string[8];


  10:                 while (!parser.EndOfData)


  11:                 {


  12:                     currentRow = parser.ReadFields();


  13:                     foreach (string s in currentRow)


  14:                     {


  15:                         Console.WriteLine(s +'\t');


  16:                     }


  17:                 }


  18:  


  19:             }


Monday, November 24, 2008

.Net Languages are becoming more alike

I was looking at the new feature of VB10 and C#4.0 in the VS2010 CTP and it appears that they are becoming more alike than they are diverging. VB10 gets the explicit line continuation, no more "_", not universally , but in a fair number of places. I also gets auto implemented properties (C# 3.0 already has this) and collection initializers among other features. C# on the other hand is getting optional parameters, which have existed in VB for quite some time.

So it seems as time goes by there is really less of a difference between the two languages that in Version 1 of the .Net framework and VS7. So at what point will they become so similar that it will not be cost effective or desirable to maintain to distinct languages with exactly the same feature set? Granted there are still some differences between the two languages, but as time goes on, there is less and less that separate them other than pure developer preference.

I suppose that there will always be the "My language is better" kinds of religious arguments but it is becoming harder for each camp to point out the differences.

The VB10 futures doc can be found here.

The C#4.0 futures doc can be found here

Tuesday, November 11, 2008

God save us from the Architects

I'm constantly reminded that bigger is not always better, especially when it comes to architecture. Enterprise architecture  in particular seems to suffer from an extreme application of "Gold Platting", because "we may need it some day" and my favorite is because it's part of the "Vision".

It is time to for enterprise architects to get back to the basics, which I define as

  • Do the simplest thing that will work
  • Do it well (if it's not worth doing right, it's not worth doing)
  • Keep the customer happy
  • Don't add complexity for complexity's sake
  • Keep it simple to deploy and configure

These simple tenets will take you a long way in development and make your life and the life of your customers better. Many markets move and evolve at a rapid pace, if you over engineer, you'll get passed by opportunities or worse by the time you finish the market will have moved on to the next big thing.