CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Grant Killian's Blog

No, this has nothing to do with beer -- but maybe it should?

June 2004 - Posts

  • Hello from the Ivory Tower

    O'Reilly has posted an interesting interview with the Pragmatic Programmers.  It shares some interesting facts about the state of software development:

    “Now some 40 percent of teams in the U.S. don't use version control at all. 76 percent don't unit test, and 70 percent don't have a daily build.”

    Based on the blogs I follow, those numbers appear atrociously inaccurate.  Doesn't everyone use a version control system?  Aren't unit tests part of the daily development process?  Isn't the daily build a tradition in your shop?  The sad fact remains, however, that the statistics are probably true

    Some colleagues of mine, particularly in larger businesses, lament the development “process” in place at their company.  It seems the bigger the company is, the harder it is to initiate change.  While I worked for a defense contractor that shall remain nameless, the explanation for this was “Steering a big ship in a new direction takes time, and we're in one of the biggest ships in the world.”  The Titanic was a very large ship, indeed.  It's enough to make process-savvy and agile guys like Darrel pack their bags . . .

    But I digress.

    The interview also offers this memorable quote:

    “If you sit in your cube waiting for a spec to be thrown over the wall, then you may be in for a wait -- that spec might be in an envelope on its way to Bangalore.“

    Offshoring is such a complicated issue, but the more I consider things the more truth I find in the quote above -- except it could be Beijing in a few more years, and maybe Bangkok a few years after that.  Like the good Bob Reselman says: “Who knows, maybe we'll go off and do something better?” 

    The blog world, generally speaking, is a haven for the overachievers; we shudder to consider projects without version control, unit tests, and have elegant responses to the outsourcing question.  Meanwhile, in the other 95% of the programming world, outsourcing is a constant and legitimate fear -- much more so than “if I write this code without a unit test, I'll sure regret it 3 months from now.” 

    I love my Ivory Tower as much as the next guy, but a dose of the brick-and-mortar tower can be a good thing too.  Blogging is preaching to the choir and offers a distorted sense of the real programming community.  Now, on to my unit tests . . .

  • Blog Quandary (Quicktime and otherwise)

    If you've got customers with help documentation or other files in QuickTime format, be sure to check this out regarding plug-in support for IE; my default browser is of the FireFox variety and this created a minor inconvenience during initial application testing: http://www.apple.com/quicktime/tools_tips/tutorials/activex.html.

    <introspective meandering=“true“>This brings me to something I've been wrestling with for a while now . . . this blog is hosted on dotnetjunkies and this post about QuickTime has nothing to do with .Net.  I had a very nice night on the town in Norfolk with bsblog last week -- although I didn't ask if “bsblog” is short for “Brendan's Blog” or “Bull Sh*t Blog” or what -- the evening gave me more incentive to pursue another project outside the dotnetjunkies domain.  I confided to Brendan that I didn't feel like I had a really high caliber blog post in 2004, to which Brendan pointed out that “you never know what part of a post is going to prove interesting/useful to somebody out there.”  I wholeheartedly agree, but to let you in on a little secret: I've avoided writing many blog posts because I feel like it's not .Net relevant.  I've been thinking about it for some time now, especially when I choose not to post about my thoughts/experiences with design, SEO, standards, javascript, and everything else that makes me tick but isn't directly relevant to .Net.  Folks with DNJ aggregators probably don't want non .Net stuff in the .Net feed! 

    I plan to maintain this blog for .Net specific stuff but I've got a new thing up my sleeve for everything else . . . besides, am I the only one that thinks the 200+ blogs on dnj suffer from too much quantity over too little quality?  Granted, my posts aren't ripped from the trenches of Microsoft's internal projects (like Don Box or Chris Sells), but I strive for a certain level of quality that isn't always maintained.  I've considered closing up my blog shop, but then I wouldn't have a chance to keep in blog-touch with so many of the friends I've made via the medium.  I like .Net and I like blogging, so I'll stick around here.  A buddy of mine, Chris Hale, just succumbed to the blog instinct and while I applaud him for joining the family, I feel for him at the same time: blogging is addictive and it's easy to waste a lot of time in this space (or to feel like you're wasting a lot of time in this space).</introspective>

    So, to summarize: 1)  I'll probably be doing less .Net blogging here (my little way of improving the DNJ feed) -- although fruitless in the face of so many other posters, like Mao said: “A single spark can start a prairie fire” so who knows where it will lead.  2)  I'm going to embark on a new online vehicle of expression, one in which I don't feel guilty about clogging up the dotnetjunkies feed and feel much more creative flexibility.  I'm excited about it.

    More details soon . . .

     

  • If you're messing with ASP.Net 2.0 . . .

    . . . you may want to check out Josh Flanagan's post announcing his new free control “that allows users to view and edit their profile information” -- check it out here.  It's inspired by the Whidbey Personalization Services and a TechEd presentation on the topic; I'm going to check it out.

    Despite the new control, I don't know that I'll forgive Josh for dragging me onto the SeaWorld Wild Arctic Ride at TechEd -- I haven't been quite right since that simulation ride let me off.

  • Domain controllers don't make good web servers

    I knew this, but one of our customers forgot it. I've spent the last 24 hours helping them recuperate from that.
  • My 1 Off-Topic Post For All Eternity, But It's Worth It

    I usually try to stay on the topic of .Net, but this is just too funny not to share -- and what the heck it is Friday.  A friend of mine stopped by my house a few weeks ago and we were looking at a database issue (you know, the usual things people do when house guests drop by), we solved the problem, talked a bit, and then he left. 

    The next day I got an email from him asking if he left his cell phone at my house; the last time he remembers having the phone was when he dropped by.  I couldn't find the phone and he figured he lost it somewhere and would have to buy a new one.

    I just got this email from him:

     I found my phone.  Evidently I set it on the coffee table when I got home and the dog ate it - no kidding.  It is no longer functional.

    Even though I can piece the puzzle together fairly well on my own, I'm very eager to get the whole story.  I'm full of questions like what went on in the dog's stomach when people called his cell phone?  Was it set to ring or vibrate?

    Something to think about for the weekend.

  • The official word on DataSet.HasErrors HasProblems

    For those of you on the edge of your seats after the cliff-hanger ending to my post about Web Service errors when DataSets contain Error rows (HasErrors = true), I'm happy to report the results of our contact with Microsoft about the issue.  After weaving through automated phone trees and navigating the layers of friendly customer service personnel, the fix to the issue is due out in Service Pack 1 of the .Net Framework 1.1.  The Service Pack isn't going to be officially available for a month or two, but for customers needing a solution to the Web Service issue I encountered,  you can download the 1.1.4322.918 version of System.Data.Dll (replacing 1.1.4322.573 that shipped with Framework 1.1) from Microsoft -- just contact them to get it (I suppose I could share the installer files if you really needed them, but I'm thinking MSFT would rather you got it from them directly).

    After the telephone leg-work with Microsoft, rather than install the HotFix on all the various machines, I think we're just going forward with the SOAP Serialization work-around I outlined in the previous post.  Just the same, it's good to know a long term solution is in the works from the good folks in Redmond.

  • Web Service gotcha: DataSet.HasErrors HasProblems

    I've spent the last few hours wrestling with the issue identified in Microsoft KB Article 818587; in a nutshell, serialized DataSet objects that have Row or Column Errors can have trouble when passed between web services to client consumers.  My specific case is an Excel-based data editor (using VSTO) that relies on Web Services for transmitting data to and from the data server. 

    Everything was going great until I started expanding the proof-of-concept to handle concurrency exceptions -- I'm dutifully using a SqlRowUpdatedEventHandler to manage concurrency errors and after I kept getting NullReferenceExceptions after passing the DataSet with the Errors back to the client, I discovered KB Article 818587.  At this point I scratched my head some and thought this through: this isn't your typical KB Resolution from Microsoft, it says “To resolve this problem, contact Microsoft Product Support Services to obtain the fix.“  It goes on to indicate the resolution is to install a new System.Data assembly, which sounds innocent on it's own, but this will throw the configuration management folks here (and more importantly, at the client) into fits. 

    A thought occurred to me: since it's 1) late in the evening and I don't feel up to a Microsoft call and 2) pretty certain our customer will not like having to run a special “patched“ System.Data dll just for this app, why don't I try to program my way out of this paper bag?

    I decided to circumvent the native Web Service serialization and try my own, to see if I could get my DataSet to successfully transfer between server and client without the magic dll from Microsoft.  I created a Serialization Helper class to convert any object into a serialized string (note: I used the very verbose SoapFormatter instead of the BinaryFormatter to ensure that my string transfers without loss of data -- yes it's slower but in this case it's a necessary evil):

      public static string getSerializedVersion( object obj )
      {
       System.Runtime.Serialization.Formatters.Soap.SoapFormatter soap =
        new System.Runtime.Serialization.Formatters.Soap.SoapFormatter() ;
       byte[] buf ;
       System.IO.MemoryStream mem = new System.IO.MemoryStream() ;
       soap.Serialize( mem, obj ) ;
       buf = mem.ToArray() ;
       return System.Text.UTF8Encoding.UTF8.GetString( buf ) ;
      }
     

    You may think: isn't this what the SOAP plumbing for Web Services does already?  Conceptually, I think that's true, but there's obviously some magic in my manual serialization of the object since it succeeds where the intrinsic Web Service serialization fails with the nasty NullRef XML exception.  This may be a bit slower, but I'll take slower code that runs over fast code that doesn't really work any day!  By the way, for this to work you'll need to reference System.Runtime.Serialization.Formatters.Soap.dll in your project.

    To use this SerializationHelper class, we can just do the following to return a string from our web method:

        theDataAdapter.Update( theDataSet ) ;
        return SerializationHelper.getSerializedVersion( theDataSet ) ;

    The flip side to this is that the client has to specially deserialize our DataSet; we can use a SerializationHelper class to do something like the following (this time I'll show VB.Net since our client using Excel is written in VB.Net, sorry C# purists, see this post for why!):

     dim strResult as string = objWebSvc.getDataSetWithPotentialErrors()
     dim soap as New System.Runtime.Serialization.Formatters.Soap.SoapFormatter()
     dim buf as byte() = System.Text.UTF8Encoding.UTF8.GetBytes( strResult )
     dim mem as IO.MemoryStream = new IO.MemoryStream( buf )
     dim obj as Object = soap.Deserialize( mem )
     theDataSet = CType( obj, DataSet )

    OK, so where does this get me?  I've managed to avoid calling Microsoft and aggravating our customer with a special System.Data assembly requirement for the project; I think I've programmed myself out of the paper bag in time to watch the Daily Show on Comedy Central! 

    I'm sure somebody from my company will contact Microsoft about the KB Resolution and our work-around, to see what the whole story is.  If it's worthwhile, I'll post a follow up.  Until then, I'm content with this approach.  I've spent some time in the various newsgroups and I'm not the only one who wrestled with this known issue, perhaps this will prevent you from spinning your wheels too long on it.

    Happy .Netting!

  • My latest little tactic (no Web Service dust involved) . . .

    . . . has been to take advantage of the Debug conditional compilation constants and Trace and Assert to my heart's content.  It also lets me circumvent some time consuming authentication code or pre-fill forms with test values, etc.  It can be as simple as the following in the global.asax Session_Start() event handler:

    #if( DEBUG )
        Session.Contents[ "Authenticated" ] = "true" ;
    #else
       //no special action
    #endif

    When you do a Debug build, the DEBUG constant evaluates to true; if you do a Release build -- shocker -- the Debug constant is false.  It's all handled automatically by Visual Studio .Net from the Project Properties->Build->Code Generation section (by default TRACE is another constant defined for Debug AND Release builds).

    I know this isn't a glitzy new feature with XML baked in and Web Service dust sprinkled on it, but it is a nice little measure to remember!  By the way, my above example using a Session variable is very bug prone . . . for production code I make a typed session manager like Mark does here.

    Happy .Netting!

  • MSDN Magazine Overload

    I was interested to see the edge of a shrink-wrapped magazine in my mailbox at work this morning . . . until I pulled out the magazine and realized it was another copy of MSDN's July issue.  This is the 3rd copy of this that I've gotten in the mail, and while I'm happy to have the information, I don't really need three printed copies of it all.  This has been happening for a number of months, so this isn't just an anomalous month!  

    I realize that through conference registrations for DevScovery and TechEd, and the role I play in the WeProgram.Net user group, I'm privy to a complementary subscription for a year or so . . . but I didn't think MSDN Magazine would just ship duplicate magazine issues my way each month.  And then duplicates of the duplicates!  I'm betting I'm not the only one in this situation. 

    I've been giving the magazine to coworkers and our user group has an ample number of people who like to take the free magazine, so I'm not complaining so much as observing that MSDN Magazine is not in the business of making money so much as they are in spreading the gospel according to Microsoft development.  I have it on good authority that MS Press is not a lucrative publishing effort, and I suppose MSDN Magazine falls under the same umbrella (although sponsor ads probably generate some nice revenue for the magazine).  Microsoft likes having the channel to the developer community that MSDN Mag provides and I don't blame them for it; this explains why we see posts like this one questioning the content choices of the magazine . . . MSDN magazine is going to generally be “on message” and in sync with the Microsoft public direction. 

    So, the moral of the story is twofold:

    1. Don't take a gift MSDN Magazine issue for granted (there's usually good content in there and if you get duplicates, they make good -- albeit small -- user group giveaways).
    2. Recognize the source of the “journalism“ in MSDN and take it with a grain of salt.  I've learned lots of interesting things from reading MSDN, but I've also skipped over articles on things like Web Classes (anybody remember those?) and close MS Passport integration.  Take it with a grain of salt!

    Happy .Netting!

  • Reflecting on the Visitor Pattern

    A few new articles are up on DotNetDevs; I contributed to this one about Reflection and the Visitor design pattern.  The DotNetDevs site has a high standard for articles, adhering to the quality over quanitity idea.  I like it.

    On the subject of design patterns, it's been said “Never hire a programmer within 1 year of having read their first design patterns book.”  While it's not meant as a real hiring guideline, there is some truth in the observation.  The tendency to abuse and over-use patterns once you're first exposed to them is a common side effect; I know I went through my “everything can be solved with patterns” phase.

    WeProgram.Net speaker (three sessions now, if you can believe it!) Steve Metsker has written a solid .Net guide to patterns: http://www.awprofessional.com/title/0321126971.  It's better than the “other” stuff that is just copied from the Java world (i.e. Metsker took some time and really applied the patterns in C# instead of just changing the source code from Java to C# like “other” books have been known to do).

    Happy .Netting!

  • De-emphasizing C#

    Some folks at the WeProgram.Net meeting last night pointed out this interesting link at infoWorld: http://www.infoworld.com/article/04/05/28/22FEvs2005_1.html

    A notable excerpt:

    Microsoft is putting Visual C++ 2005 back at the top of the food chain. When Microsoft released VS .Net, it assumed that C++ developers would jump to C# en masse. Unmanaged — compiled to machine instructions — code was deemed primitive, dangerous, and exploitable. VS .Net derailed Visual C++ to encourage C++ developers to evolve into more civilized and enlightened C# beings.

    New efforts on behalf of Visual C++ 2005 suggest that Microsoft has backed off the C# hard-sell.

    And: 

    The best feature of VS Team Foundation may be its completely rewritten SCCS (source code control system). This replaces the weak Visual SourceSafe, which provided only basic

    source-code control to small groups of developers. Microsoft estimates that VS Team Foundation will scale to handle as many as 500 developers per group.

    Food for thought.  I've heard from other sources, too, that C# will not be as emphasized as it has been.  This bums me out, a bit, as I took to C# because of my familiarity with Java and it seemed very natural.  I know a lot of companies that consider C# their premium development language and I wonder what all this means for those shops?  I'm not sure I buy into the infoWorld's analysis on it.  Is Microsoft jerking us around on C#, or is this misguided infoWorld-speak? 

    As for getting rid of SourceSafe, it's long overdue.  What I've seen of the Team Services for VS.Net 2005 is very slick as it integrates code coverage and unit testing into the VS tool, not to mention task management and other niceties.   

    Happy .Netting!

  • System.NullReferenceExceptions vs System.Xml.Xpath.XPathNavigators

    Our local user group, www.WeProgram.Net, is holding the annual .Net cricket match this Saturday between the NullReferenceExceptions and the XPathNavigators.  The NullReferenceExceptions have a dark and dreaded reputation, and are known for their physical play (is there physical play in cricket?).  The XPathNavigators, on the other hand, play a speedy and quick brand of cricket that is appealing to purists of the game.  It should be an entertaining match!

    If you're in the Hampton Roads area and want to get in on the action, both the NullRefs and the XPathNavigators are looking for players; no prior cricket experience necessary.  If you can't tell already, I don't know much about cricket and I'm helping to organize the event, so everyone is welcome!  Fan support is welcome, too.  WeProgram.Net is sponsoring picnic goodies and it should be a fun and relatively code-free (except for the programming humour, if there is such a thing) event. 

    The likes of Mark DiGiovanni and Darrell Norton will be there, but I'm not sure on which team they'll be on.

    Get out from under those fluorescent lights already!  The weather forecast is good for Saturday, so it'll be a great event!

  • 17 lines of C# to 1 line of VB.Net

    I'm part of a team doing a presentation on MS Office and Web Service integration next week, and while I generally prefer programming in c#, when doing this MS Office work and using the Visual Studio Tools for Office, I prefer VB.Net.  Check out the VB.Net syntax to open a file compared to C#:

    ' Visual Basic
    ThisApplication.Documents.Open( "C:\Test\Test.doc" )

    // C#
    Object filename = @"C:\Test\Test.doc" ;
    Object confirmConversions = Type.Missing ;
    Object readOnly = Type.Missing ;
    Object addToRecentFiles = Type.Missing ;
    Object passwordDocument = Type.Missing ;
    Object passwordTemplate = Type.Missing ;
    Object revert = Type.Missing ;
    Object writePasswordDocument = Type.Missing ;
    Object writePasswordTemplate = Type.Missing ;
    Object format = Type.Missing ;
    Object encoding = Type.Missing ;
    Object visible = Type.Missing ;
    Object openConflictDocument = Type.Missing ;
    Object openAndRepair  = Type.Missing ;
    Object documentDirection = Type.Missing ;
    Object noEncodingDialog = Type.Missing ;

    ThisApplication.Documents.Open( ref filename,
        ref confirmConversions, ref readOnly, ref addToRecentFiles,
        ref passwordDocument, ref passwordTemplate, ref revert,
        ref writePasswordDocument, ref writePasswordTemplate,
        ref format, ref encoding, ref visible, ref openConflictDocument,
        ref openAndRepair , ref documentDirection, ref noEncodingDialog ) ;

    Is my point clear?  17 lines of c# to 1 line of VB.Net.  C# becomes a very verbose way of working with the object models -- this isn't just for the Documents.Open method, it's everywhere.  Of course, one could write a helper object to handle these Type.Missing parameters, but a truly universal helper object would have overloads with every reasonable combination -- something I certainly won't waste my time doing just to say “This was done in C#.“  Microsoft doesn't provide a helper object, either, so they figured it wasn't worth their time.  I won't even discuss the get_Item syntax in C# for accessing Office collections . . .

    Divergence between C# and VB.Net is supposed to be on it's way . . . future releases of the language and editor will make C# a tool more for component and system developers and VB.Net a tool more for rapid application development . .. but in the world of Office development there's already a big difference between the two languages!  If you're getting paid by the number of lines of code, then C# wins hands down!

    Pick the right tool for the job and use VB.Net for Office development!  If you want to attend the presentation, get to the www.WeProgram.Net meeting next Tuesday night.

    Happy .Netting!

More Posts