Monday, December 10, 2007

Blogging on Elegant Code

I have joined up with a group of Boise Developers who have a combined blog roll.  Hopefully it gives a more structured area for my post on technology.  I will continue to maintain this blog as a blog for personal views and comments but my professional postings will be on elegantcode.com from now on.

Gigabit Networks at Home

I have been following Scott Hanselmans notes on his Ggigabit network. At first I considered it no big deal, but after reading this Wiring the House for a Home Network I am definitely going to look into it. I thought I was doing Ok (I get about 7 Megabytes per second) but apparently I am off by a factor of 10. Need to check the wiring and the frame sizes. Unfortunately I can not do anything about the Vista SP1 issue until I can get on a beta or something.

Sunday, December 9, 2007

Some of my friends are slackers...

A good friend of mine (Scott Nichols) has been slow to take up blogging. I would usually cut him some slack but Scott has some great ideas and a great understanding of software development and .net. Hopefully we will see him kick off a few posts in the next month. I know he got some flack at the installfest :-).

Boise VS2008 Install Fest

Well I had a good time presenting at the Install Fest. In addition I learned a great deal about VS 2008. Jason is a good speaker. I always enjoy what he has to say. In addition Chris gave a talk in with like 20 minutes of prep time. That guy is amazing.

I have been working on a few projects for the last few months that show off some capabilities of VS 2008 and support my gaming habit (strictly dnd 3.5, no console games). I have created a project on CodePlex and will release the code under the GPL. That gives me a project to show off some features with with out having to release any customer projects.

I will post full details on how to get to it in the next few days once I get everything there.

Thursday, December 6, 2007

Visual Studio 2008 Training Kit

Microsoft has released a training kit for Visual Studio 2008. You can get it at

http://blogs.msdn.com/daiken/archive/2007/11/19/visual-studio-2008-training-kit-now-available.aspx

Definitely worth picking up.

Cool Things in .NET 3.5

This does require Visual Studio to upgrade the database. I am using the Visual Studio Professional Trial for now.

So download the sqlce database from http://www.andargor.com/. Unpack the zip file to the C:\SQLMETAL directory. Now upgrade it according to Microsoft's Instructions at Upgrading CE from Earlier versions.

Next open a Visual Studio Command prompt and change to the directory where you have the compact database from above.

type in the following command

sqlmetal /code:srdce.cs /namespace:d20 /pluralize /serialization:unidirectional /language:csharp srdce.sdf

Open the file srdce.cs in Visual Studio. You now have a class library representation of the database and tables in the srdce.sdf database (in my case it is 6600+ lines of code) with full attributes for the database columns and tables with 10 classes (one per table) that describe the columns of each table and on class name srdce that has the collections classes for each of the table.

Now open a new C# class library (dll) project in Visual Studio named srdce and add C:\SQLMETAL\srdce.cs to it as a C# class.

Next add references to System.Data.Linq and System.Runtime.Serialization. Now compile once for a test to make sure you got everything right.

Next add a new test project to the solution named srdcetest. Add a project reference to the srdce project to the srdcetest project. Right click on the node for srdcetest and select add/Unit test. This will generate unit tests for all the classes generated from the database.

Next compile the solution to make sure everything works. Now go to the Test Menu and select "run all tests in solution". All the test should fail with a Assert.Inconclusive.

So now we do a little of the red/green/refactor thing. All of our tests fail, so we got red down. Now I want to have a test pass. So goto the SkillsTest method in the SrdceTest class. Change the code to

//IDbConnection connection = "d:\\sqlmetal\\srdce.sdf"; // TODO: Initialize to an appropriate value
Srdce target = new Srdce("c:\\sqlmetal\\srdce.sdf"); // TODO: Initialize to an appropriate value
Table<Skill> actual;
actual = target.Skills;
List<Skill> SkillList = new List<Skill>();
foreach (var Skill in actual)
SkillList.Add(Skill);
Assert.AreEqual(SkillList.Count, 40);

Now go to the using block at the top of the test class and add

using System.Collections.Generic;

Now go back to the SkillsTest method and right click and choose run tests. This should complete correctly.

So we have taken a database, created a class hierarchy for it, created some unit tests, refractored a unit test to be green and basically the result is as follows:

  1. We now have a done a ORM mapping between a database and a C# class hierarchy.
  2. We generated 304 Unit Tests.
  3. We proved that we can select all the data from the skills table and put it into a list for later use in the application. The list is a strongly typed list of the base data type.

Pretty cool, eh?

In later entries I will show how to create a database from the class hierarchy and how to persist data to the database. Finally we will look at how to make the class hierarchy a set of dll's that can be used as plugins in a application.

Wednesday, December 5, 2007

kindle - Part 2

Ok. This is a way cool device. Had to be the easiest way to read the Journal ever. Must say all the financial articles amaze me. When did Russia become Europe's energy provider? I did not know Hillary had voted the same for a lot of the stuff for the Iraq war. Finally Guantanamo is going to eat Bush alive if the supreme court goes against his imprisonment tactics.

You do have to read the thing with the cover on though. Otherwise you start hitting the wrong keys. With the cover on it is almost like a paperback book though.

Kindle

My Kindle came in from Amazon.com yesterday. I had already purchased 80 or so Ebooks to try out on it. Most are older science fiction that are very tough to find today. Out of print etc. I also subscribed to the Wall Street Journal and Time Magazine. I have always enjoyed reading the Journal in the morning, but usually found the hassle and waste of throwing away the paper too much. Same for Time Magazine. Now no more paper to throw away but I can still read the Journal every morning. Very nice.

I have also found some of the older Science fiction is the actual pulp version from astounding. Apparently these were scanned to make the ebook version. Reading the original Skylark stories and seeing the pulp drawings from the original astounding articles is very cool.

I also like the fact that I have 80 books with me in a device the size of a paperback book. Much more portable then a laptop. I will probably start purchasing all the new books I want this way. The price on a new hard bound bestseller for example is only $10 vs the $30 or $40 I would normally pay. I picked up Churchill's History of world war II for about $6 bucks a book. I have the collectors version setting on my book shelf, but it does take up most of a shelf :-).

A primary motivator for me to buy the kindle was I was running out of book shelf space. The garage is full on both walls, there is a wall full in the living room, a wall full in both bedrooms. I only have about 1.5 shelves free so I am being careful about what books I buy. Now with the Kindle I will buy them first in Kindle format and then buy the hard backs only when I want collector versions.

I figure this will both save me shelf space and money. In addition I will start trying to buy most of my technical books in Kindle format. These usually are only useful for about 2 years before they are obsolete so at least now I won't have obsolete books taking up shelf space. The only thing I might miss is the source CD's but those are usually online any way. I probably spent a good $1K on this beast between the Kindle for $400 and the 80+ books. So far it looks to have been very well worth it.

I plugged my 1 Gig SD card into it. I had this in my old windows mobile phone but my new phone could not use it. It had to be a mini sd card. So the new windows mobile phone now has a 4 Gig mini sd card in it while the Kindle has another gig of memory for books. I figure that is some where around 1200 books I can carry around in the Kindle before I will have to upgrade to a 4 gig card or something. Of course by that time the kindle will be out of date and I will buy a new one :-)