Friday, October 19, 2007


I've been reviewing the ExcelPackage project on CodePlex. It is a useful project but one thing I was wondering is why does it directly interact with the XML?

I think it is a performance and a code maintenance hit to work directly with the XML for the workbook and worksheets. In my oh so humble opinion I think it would be easier to create plain old C# objects to work with the cells, rows, sheets, etc. and then serialize and de-serialize as needed. I say this because in the XML for a worksheet the cells are stored in XML nodes that have the row number and individual cell addresses in them:



So if we work directly with the XML what has to happen when we insert a row? We have to loop through all of the XML nodes and update the row values. Note that I am not even talking about how to deal with merge cells or ranges (which the ExcelPackage does not work with).

I think that creating a Attribute-value system would be a better approach. Rows and Columns could be a linked list, Cells could be in an indexed cache or hashtable. And the collections and individual objects would handle where they were in the domain of the spreadsheet.

Guess I should get busy and prove my point.

Wednesday, October 10, 2007

EntLib Data Access Block and Excel

I need to be able to open an Excel workbook and grab the data from one of the worksheets. I don't want to use any Office InterOperability (as that sucks) and I know I can do it using ADO.Net. But since 1.) I hate writing all of that DataAdapter / Connection code because 2.) I am lazy I decided to see how hard it would be to use the EntLib DAB.

Turned out it was pretty easy.

Create your configuration as such:

Then call your code as such:

public static DataSet GetWorksheet()
string sql = "SELECT * FROM [Sheet1$]";
string connectionName = "Book1";

return DatabaseFactory.CreateDatabase(connectionName)
.ExecuteDataSet(CommandType.Text, sql);
And that is that. One DataSet ready to go.

Crappy Apps

Why is it that so many crappy apps are out there in the wild?

Is it because of the visual tools available in the .Net realm that generate so much crap that the average programmer just does not have time to clean it up? Or are the developers just too lazy to clean up the mess as they go?

Saturday, June 16, 2007

CueCat vs the USB Keyboard

Ages ago I picked up one of the RadioShacks CueCats but I never used it.  Up until today it sat in a box of computer junk having survived several purges.  You know Purges:  You have so much junk you have to get ride of the old.

I never got ride of the CueCat because barcode scanners are not cheap, which I do not understand.

Any way, I came across Scott Hanselman's article on a .Net app for the CueCat, Coding4Fun Hardware Boneyard - Using the CueCat with .NET, and decided to break out the old dusty cat and give it a spin.

The code was no problem, getting my machine to read the CueCat was.  See, I have a Logitech wireless keyborard and mouse so Windows XPdid not load the PS/2 drivers.  I wound up having to dig up an old PS/2 keyboard (from the same junk box, you should always have PS/2 keyboard and mouse handy!) plugged it in, rebooted and vola, it worked.

Now I am off to inventory my CD collection.  And my books.  Maybe the comic books.  If I do the pantry my wife my smack me.... 

Thursday, June 07, 2007

Chevy Vega vs. TestDriven.Net

My Dad originally made a living as an auto machinic and working on cars is still his favorite pass time. Besides working on cars my Dad liked to swap cars. Swap cars, car parts, you name it he would swap it. The benefit of that to me was that I was exposed (read - drove) to a lot of different cars, some clunkers some not.

One of the cars he swapped for was a Chevy Vega with a 327 small block V8 in it. That little car was freaking FAST and I am surprised that he actually let me drive it at all. I recall that I broke at least three speed-odometers just from peeling out.

Now Chevy did not make a stock Vega with such a powerful motor. No, someone got the bright idea to take out the crappy four banger that was in it and replace it with a 327 small block V8 with a 3/4 inch racing cam and a Herts speed shifter. They even had to take out the cross bar member on the front end so that the motor would fit in the tiny Vega, which made the tires sit funny when it was parked.

And you know we never got any letters or phone calls from the Chevy folks telling us that our little hack was a violation of any agreement we made when we bought the car. None of their lawyers gave us a deadline to remove that 327 small block from that Little Ole' Vega because it was not designed to have it in there.

No, they were busy trying to design and build cars that people would buy. They let the hobbyist and users hack their cars however they saw fit. And if a hacked car was swapped or sold so be it, there were plenty of other people out there that wanted a brand new car. The car with the new car smell and show room shine.
So Microsoft has a cute little tool called Express and it is for the hobbyist. Doesn't Microsoft know that hobbyist like to ripe into things to see how they work? Haven't they been following the Make movement? Don't they know that the hobbyist really wants to put the big screaming fast race engine in that little car?

And isn't TestDriven.Net free to use for personal use? Like Express? So what is the harm? The harm in what Microsoft is doing is it is killing the community. If the hobbyist is afraid to use Express, or they feel that they are artificially limited in what they can do with Express then why would they want to use it?

Microsoft pays my mortgage and I really have no animosity towards them. But sometimes I just have to wonder.

Saturday, March 31, 2007

Learning TypeMock.Net

We need to implement a better unit testing strategy at work but unfortunately we have code that is not written to be unit tested. Our unit test rely on the state of our database and this has caused so many issues that I'm hesitant to even run them.

To fix the issue I have started working with TypeMock.Net an AOP mocking tool.  TypeMock will intercept calls to objects that are called by the code you are testing without actually creating or executing the object.  I'm still fuzzy on the details but I plan on using this tool to help me test some pretty untestable code.

Wednesday, February 28, 2007

Scratch Programming

I have started doing more scratch programming, one off little bits of code that I use and throw away. I found that I am not coding as much at work as I need to be, or want to be for that matter. I am loosing my touch.

Like any thing else, if you don't use it you loose it.

When I create projects I like to follow a specific file structure. Nothing fancy, I use a solution folder with folders for lib, src and tests. So when I create my scratch solutions I want to create the same folder structure, but there is no easy way to do it with Visual Studio. I tried to create a project template, which would work if what I wanted was skeleton projects. But what I want are skeleton folders and the VS templates won't create those.

What I wound up doing was create an MSI using NSIS that would create the folder structure and copy core libraries that I like to use. So far it is working out pretty good and was surprisingly simple to create, not by hand of course but with HM NIS Edit, a free tool to create and edit NSIS scripts.
; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Scratch Template"
!define PRODUCT_VERSION "1.0"
;!define PRODUCT_DIR_REGKEY "SoftwareMicrosoftWindowsCurrentVersionApp PathsMbUnit.Cons.exe"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
;!insertmacro MUI_PAGE_LICENSE "............\path\to\licence\Your\SoftwareLicence.txt"
; Components page
; Directory page
; Instfiles page
; Finish page
!insertmacro MUI_PAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

OutFile "ScratchSetup.exe"
InstallDir "$DOCUMENTSVisual Studio 2005ProjectsScratchNewSolution"
;InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "GenericSolution.sln"
CreateDirectory $INSTDIRlib
CreateDirectory $INSTDIRsrc
CreateDirectory $INSTDIRtest

Section "MbUnit" SEC02
SetOutPath "$INSTDIR\lib\MbUnit"
SetOverwrite try
File "\lib\MbUnit\MbUnit.Framework.dll"

Section "Log4Net" SEC03
SetOutPath "$INSTDIR\lib\log4net"
File "\lib\log4net\log4net.dll"

Section "Enterprise Library (June 2006)" SEC04
SetOutPath "$INSTDIR\lib\EntLib.2006.01"
File "\lib\EnterpriseLibrary.2006.01\EntLibConfig.exe"

;Section -Post
; WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\lib\MbUnit\MbUnit.Cons.exe"

; Section descriptions
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} ""

Add the appropriate files to the Sections, compile and your ready.

Wednesday, January 24, 2007

Saturday, January 20, 2007

Worm Hole to the Universe

So I downloaded Google Earth and was playing around with it when I found the Worm Hole to the Universe. Its amazing what can be found out there.

Friday, January 12, 2007

David Hayden [MVP C#] : Validation Application Block - Integrating It Into Your Business Layer

Now that we have this cool Validation Application Block we want to use it with all our business objects. This should immediately send up a red flag that there will probably be some common functionality among all these business objects in how they use the Validation Application Block. Hence some type of layer supertype ( business base class ) will probably be necessary to contain common functionality to remove code redundancy.

Source: David Hayden [MVP C#] : Validation Application Block - Integrating It Into Your Business Layer

David Hayden presents another great article, this time on the newest addition to the MS EntLib: Validation Application Block.

I go back and forth on the EntLib as a whole. Parts are great, other parts are overkill. I love the Data Access Block and use it in tandem with my other data access frameworks (ActiveRecord, NHibernate, etc). The UI block though, WTF!

David's article is a good read. Go forth and read.

Thursday, January 11, 2007

No, wait, I am Dr. Doom

If I were a villian I would be

Dr. Doom

Dr. Doom
Lex Luthor
Green Goblin
The Joker
Dark Phoenix
Mr. Freeze
Poison Ivy

Blessed with smarts and power but burdened by vanity.

Click here to take the "Which Super Villain are you?" quiz...

Friday, January 05, 2007

Top four reasons Windows wins and Linux loses


Top four reasons Windows wins and Linux loses

1. The Installed Base

2. PC Vendor Support

3. Hardware Vendor Support

4. Software Support

Source: Top four reasons Windows wins and Linux loses

To this list I would like to add:

     5. Consistent Package Installation

In windows you have MSI files to install stuff with.  They are simple to use and pretty much standard for every program I've installed.

In Linux I've used RPM's, APT and PORTAGE.  Granted they are all easy to use it is still frustrating to me to have to know how to use all three.  The less I have to think about something mundane (i.e. installing software) the better it is.

What would really rock Linux's world would be a single distribution system that would work with all distributions.  That way the distributions could work on making their distro better and not have to worry about maintaining an Open Office or FireFox install.