Friday, July 28, 2006

I really don't like the C# "as" operator.  I have to admit that I made it a point not to use this solely because it made me have a brief moment of "VB.NET flashback".  I personally have a strong dislike for VB.NET syntax but that's just my preference.  Because of my VB.NET bias I did not look at the C# language spec to see if "as" functioned differently from

string foo = (string)myType;

As it turns out I tracked down a difficult bug in our system that was due to the fact that using "as" returns a null reference rather than throwing a class cast exception like c-style casting does.  Granted part of the problem was people swallowing exceptions in code, but I'm wondering: under what circumstances would one want the behavior that "as" provides?

.NET | Rant
Friday, July 28, 2006 9:35:19 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [4]  |  Trackback
 Tuesday, July 25, 2006

I am doing a new gig at the Land of Beer, Miller brewing.  Sean McCormack got me involved in an agile project here on a short time frame so I've not had a ton of time to blog lately.  There's a lot to talk about as this project slows down though.

I cannot say that I am a test driven development expert by any means.  However, upon arriving on this project and trying to retro-implement unit tests for a bunch of code that had no tests before I have come to a new understanding of the value of unit tests for regression testing, and for a specific aspect of the TDD paradigm.  Upon arriving and going over the projet I'd seen that the team lead was printing out class diagrams, going through the unit test packages, and checking off Method names that had a test.  I had kept meaning to look at code coverage tools in the past and the sheer amount of tests odewe needed made me look a little more seriously.  As it turns out they were already using TestDriven as part of the developer setup.  TestDriven is by itself a great tool and will have a place in my toolbox henceforth.  TestDriven installs an interesting right-click menu in VS2005 that gives you various options for running tests at the class/method/project/solution level.   More interesting to me at the time was the "Test With --> Coverage" option.  If you don't have Team System it tells you to go install NCover which I had not used before.  NCover is actually a very solid code coverage tool.  You can probably see where this is going and certainly TDD experts will file this under the "duh" department.  TestDriven + NCover + NUnit = tells you how much of your code is covered by unit tests.  NCover is smart enough to show you if, for example, you covered all the various "if()" branches inside a method and such.  This is Very handy and not just for unit tests.

We found, in general, that the application had "thong-level coverage" from unit tests; as any good christian will tell you the thong leaves too much uncovered!  We strove to get it to "Burqa-level" coverage and made a lot of progress before the timeline demanded we start on new development.

Upcoming rants:

"About Casting"

"Funny Stuff I've heard at work recently"

"Indirect paths to success"

Looks like I have some invalid HTML in here somewhere, the visual styles on the links are hozed.

Tuesday, July 25, 2006 9:32:51 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Thursday, June 29, 2006

I just completed an "alpha"  version of a for-fun website related to my audio hobby: http://www.klipschcorner.com/

I have not had to do much in the way of web design for a while but I set out to make this design work using only CSS and DIV tags, tables are the way of the past or so I read.  I had a fairly frustrating time at this.  The last time I had to do any kind of real layout was a couple of years ago.  It seemed that you could pretty easily support a good layout with Firefox and IE without creating conditional code by using some basic CSS stuff and tables for layout.  With the current CSS implementations of IE, Firefox, Safari it seems that I'm back in 1998 with even some very basic things looking radically different in each browser.

 

Thursday, June 29, 2006 12:19:28 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, June 19, 2006

For various reasons I've had to get back into unmanaged code in C++.  This turned out to be a lot worse than I thought it would be.  My college courses were in C++ and I did a little OpenGL programming using visual C++5 or 6, and my first job was doing a lot of cool C++ stuff.  However, that was most on the Solaris platform using stuff like Vi, the sun workshop compiler, and the RogueWave libraries for things like Time, Strings, and Money.  I never got into MFC or programming C++ on Win32.  Obviously things like LPSTR and "DEF" files and such are completely new to me, if it wasn't for Chad Albrecht I would have lost my mind already.  When I take a look at the things that are coming up on my plate, though, I can see that this isn't necessarily going to just go away, SO...

If anyone can recommend some good literature for getting into MFC and Win32 programming using eVC4 and/or VS2005 I'd appreciate it.

.NET | Rant
Monday, June 19, 2006 12:05:11 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Monday, May 22, 2006

Here is my bug from Friday.  I have code something like the following that works in SQL CE 2.0:

string sql = "select field1, field2 from Table";
string conStr = @"Data Source=\Stuff.sdf";
SqlCeConnection con = new SqlCeConnection(conStr);
con.Open();
SqlCeCommand command = new SqlCeCommand(sql, con);
SqlCeDataReader reader = command.ExecuteReader();
SqlCeCommand updateCommand = null;
StringBuilder message = new StringBuilder();
while (reader.Read())
{
object[] vals = new object[reader.FieldCount];
reader.GetValues(vals);
if (null == updateCommand)
{
//... if first record, build update command
DataTable dt = reader.GetSchemaTable();
foreach (DataRow row in dt.Rows)
{

string colName = (string)row["ColumnName"];
message.Append(colName);
message.Append("=");
message.Append(row["ColumnSize"]);


}
}
}

This code merges data from "temp database" into permanent database.  Due to the # of tables merging the commands are built by reading the schema of the tables in the to-be-merged database.  Some of this code I inherited from someone else, and it works, or I might see about using  SqlCeCommandBuilder, but that is a post for another day.  This code reads all records from a merge table, and if it is the first record, build update and insert commands using the Schema Table.  In SqlCE 2 this works fine.  In SQL Mobile, if you call GetSchemaTable() after you have read the first record from the reader then the ColumnSizes contained in the schema table will be incorrect, reflecting the data in the current record rather than the schema of the table.  This results in things like truncated data errors if the first record has 5 chars in a varchar(20) field, etc.  The code works as expected if the GetSchemaTable() method is called before you begin reading records.

I can't find anything in the doc describing this as expected behavior, so its submitted as a bug.

Monday, May 22, 2006 8:19:04 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, May 19, 2006
I found a great SQL Mobile bug with ColumnSize today which I can reliably reproduce.  I am going to go find out where I submit this bug and scheck to see if its already been submitted, and then post an exaple here of how to reproduce it.
Friday, May 19, 2006 4:17:28 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Tuesday, May 16, 2006
Tomorrow night I will be speaking at the Fox Valley .NET User's group, giving a presentation of the Compact Framework version 2.  If you're in the Appleton area, stop by and say hi.
Tuesday, May 16, 2006 1:53:47 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Wednesday, May 10, 2006

For now I will be using StarUML, untill I find something incredibly annoying with it or I find something better.  This tool has full support for UML 2.0 diagrams and semantics, seems to be a native win32 app (not some mind numbingly slow Java gui) and is generally straightforward.  StarUML also includes the notion of an "approach" to modeling: Basic approach, 4+1 view model, Rational Approach, and UML Components approach.  UML components was a great, precise,  but seemingly little known book written by a couple of modeling old-schoolers, one of whom was the author of Object Constraint Language, annexed to the UML.  I figured any tool that has a UML Components icon has to be on the right path and I spent a lot of time learning this tool.

Here is a partial class diagram I just did:

And a sequence diagram I am starting on with an idea of what the UI looks like

My complaints are small so far.  There are some user gestures (like Ctrl-Tab to switch documents) that I'd like to see impemented.  One nice thing that Visio and other tools do is to route relationships/connectors with only right angles which I think looks very nice.  StarUML has the ability to export models in XMI or Rational specific format as well, mitigating the risk that I'll change my mind and go with another tool later and need to scrap the drawings I have.

Wednesday, May 10, 2006 1:17:41 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |  Trackback