Tuesday, August 01, 2006

private const string DOLLAR_SIGN = "$";
private const string COMMA = ",";

Hmm...

.NET | Rant
Tuesday, August 01, 2006 1:11:20 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [2]  |  Trackback

Which bit of code do you think is more maintainable by someone other than the original developer:

if(_speakerTypeCode == 543678){

//do something

}

or

enum SpeakerTypes {

HornLoaded = 543678,

Electrostatic = 12334
}

if(_speakerTypeCode.Equals( SpeakerTypes.HornLoaded)){

//do something

}

I'm still amazed at some of the things I find in code, sometimes even my own code.  The above monstrosity is not mine, although I do occasionally find something abhorrent in my own code.  I read a blog recently, I believe it was the Shade Tree Developer, who said that this is a great way to gage personal growth.  Go back and look at code you wrote and see if you find things that you'd never do today.

.NET | Rant
Tuesday, August 01, 2006 11:52:54 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [52]  |  Trackback
 Sunday, July 30, 2006

I upgraded to the latest version of DasBlog.  Everything appears to be working great.  Hooray.

Sunday, July 30, 2006 12:14:06 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 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