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

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

May 2004 - Posts

  • Does .NET Need Separate Date and Time Classes?

    The DateTime class is awesome.  The things you can do with it are unlimited.  TimeSpan is really cool too. But often, I find myself needing a separate Date class, without time information and a separte Time class without date info. Why do I need this? 
  • The .NET Gnome #4

    Again, any similarity to real life DBA Trolls is purely coincidental.

    All .NET Gnome Cartoons

  • A Mosh Pit in The Blogosphere...

  • A Simple InfoPath Web Viewer Control

    Here at the Port, we recently needed to allow different people in the company to quickly publish forms to our public web site. When I was tasked with making this happen, my first thought was to create a simple web-based tool for form creation.  Now, I've done this before, and creating a web-based form designer is no easy task, so  I started thinking of other options.  I could let them use FrontPage to create the forms, and then I could integrate the form into our site.   Honestly, this seemed like it would be more trouble than it would be worth.  Using FrontPage isn't a skill that most power users have.   On top of it, FrontPage doesn't create XHTML, and I wanted to end up with a document that I could parse if I needed to.  On top of all that, I remembered that I really dislike FrontPage...

    Then I remembered that everyone here has Microsoft InfoPath installed.  I figure it's only a matter of time before people learn to use it, and in my opinion, it's easier to design a form in InfoPath than FrontPage.  The problem is that putting InfoPath forms on the web isn't so simple.  The end user has to have InfoPath installed in order to fill out an InfoPath form.  Since we wanted to publish the forms to our public site, this wasn't going to be an option. 

    So, I came up with a quick solution that solved my problem.  I created a simple InfoPath web viewer that renders the InfoPath form as an HTML form, then takes the results from that form and creates a DataSet.  The resulting DataSet can then be bound to a WebControl, stored in a database or as stored as XML.

    The way this all works is simple.  InfoPath has an option to “Extract Form Files.”  This creates, among other things, an XML and XSLT file that can be used to generate the UI of the form. I created a control that transforms this into XHTML, and then does some massaging using a NodeReader and some Regex to create HTML form input elements.

    So, here's what an example form looks like in InfoPath:

    ...and here it is displayed by my InfoPath web viewer control:

    You can download the ASP.NET C# project here.

    Now there are a couple of big caveats to this control:

    • It doesn't integrate the results back into infopath format.  I'd rather have a DataSet, so that's where the results end up.
    • I only coded Text Areas, Text Boxes, Radio Buttons, and Drop Down Lists. Infopath has a number of other controls, that you can drop on the form.  I didn't need them immediately, so I didn't code support for them.
    • I didn't implement any form validation..

    Now, if you peek at the code, you'll see that I used a combination of a NodeReader and REGEX to make this work.  A better solution may be to create a single XSLT file that does this work, but I'm not that good with XSLT syntax, so I didn't go down this route.   Anyhow, try it out!

    -Brendan

     

  • "Captiopm is herk" and other goodies from SD Times

    In Issue #102 of SD times, there's an insert devoted entirely to “Leveraging .NET Components.”   Now, mostly this is a “Special Advertising Section” kind of thing, but there's a good article by Larry O' Brien called “The Face of Interface” that talks about reuse of UI components.  

    This is something I think about a lot, UI reuse.  Lets' face it.  For the most part, we developers suck at making UI.  For example, have you ever noticed that most developers can't seem to figure out how to turn table borders off, when using tables to format a form?  Anyhow, this is a big tall soapbox for me that I don't have the energy to get up on right now, but I do think that UI Inheritance and reuse are going to be our saviors in this area.

    Anyhow, there are some good nuggets in this article, like this one here:

    “a class with many public elements can be difficult to keep in a stable state.“

    Now, lately I've been doing a bunch of framework refactoring, and I wish this idea had been put in my head a year ago.. 

    But my favorite quote from the article is a caption for a figure, which says, simply :

    “Captiopm is herk”

    Now, maybe they rushed out this issue, which mags like this one are prone to do, and this is an error.  Or maybe Captiopm really is herk.  I'll never know, but I'm going to keep both of these nuggets in mind the next time I go do do some framework architechiture work.

    -Brendan

  • The .NET Gnome #3

    So, thanks to my buddy D-Ral's suggestion, I'm dropping the “.vs the Network Ogre” part of this cartoon's title and in honor of that, I'm introducing a new character. 

    All characters that appear in this cartoon are completely fictional.  Any resemblance to actual Gnomes, Trolls and Ogres is purely coincidental.

    All .NET Gnome Cartoons

  • The .NET Gnome vs. the Network Ogre #2

    Here's the rest of my encounter with the Network Ogre about his SMTP server.  Since then, I've experienced numerous other fit-for-a-cartoon encounters at work with the Ogre, and a new character I'm going to introduce next time (if there is a next time), the “DBA Troll.“  In fact, I seem to end up with a new cartoon every time this particular individual comes into my office..

    -Brendan

    All .NET Gnome Cartoons

  • The .NET Gnome vs. the Network Ogre

    Well, I hope I'm not trying to be too much like Rory Blyth.  He seems to have cornered the market on .NET cartoons so far.   But I had an another encounter at work today with the Network Ogre.  Instead of describing what happened, I made a cartoon.  Now I'm not making this stuff up..  Maybe I'll make this into a series...

    All .NET Gnome Cartoons

  • People giving comments think they're totally anonymous... Do you think we should tell them the truth?

    A while back someone spammed a bunch of blogs with weird comments, possibly thinking that they were totally anonymous.  Now, if you have a blog, and it's run using .TEXT, like the blogs hosted on dotnet junkies, you already know that along with the user's comments, you have access to the user's browser IP address. 

    Now, if you know even more about networks,  you know how to find out information about the user who sent you a comment, using this IP address.   Often, with a little luck and guessing, you can get a pretty good idea who that person is. 

    Like, earlier today, I got a strange comment from an anonymous person.  Using tools like this one, and this one here, I can figure out the longitude and latitude of the network, generally speaking.  Do you think we should let people know this, before they post crap to our blogs? 

    -Brendan

  • New IE Features I'd like to see ... all my dumb ideas.

    So, when I was thinking about new IE features that I'd like to see (like “Grabby Scrolling“), I thought of a bunch of stuff.  In hindsight, most of the following ideas are either just plain dumb, won't work, unnecessary or all of the above.  But, since I'm blogging and putting off my next project, i thought I'd post them here:

    Multiple Home Pages: the idea here would be to allow multiple home pages to be defined.    I usually have 4 or 5 sites that I go to every day, that are equally essential.  I'd like to have a drop-down on my home button that gives me the option to go to any of my pre-defined home pages.. Kinda dumb idea, if I do say so myself.

    Print Regions: Like Excel, I could define a print region of my page.  That way I can just select an area of a page to print, without ads, etc. Why is this dumb?  I'm not sure really, it's kinda confusing, and the UI for this wouldn't work very well.

    Magnetic Mousing: When I move my mouse near a clickable object, it snaps to that object's center.  This is a terrible idea. I'd hate this.

    My Keywords: Define your keywords up front, and if you navigate to a page that has that word or phrase on it, you're alerted. Bad idea. How stupid do I think I am that I can't do this with my own eyes that god gave me?

    Shared Favorites: This would hook into messenger, or something like that so you could share favs with a buddy.  This is already out there.  Stupid idea, and someone else got to it first.

    Surf Later:  An option when you right click on a link that creates some sort of to do list somewhere. Um. What do I think IE is, friggin Outlook?

    So there they are, all my dumb IE ideas.  Now I can get on with my life. ;)

    -Brendan

  • Run a .BAT file from ASP.NET

    Okay, running .BAT files from ASP.NET using  the System.Diagnostics.Process object and static methods this should be easy, right?  Well, this might work for you, but it certainly won't work on my machines. And after doing lots of reasearh on the issue, it seems that other people are also having problems with this too.  

    I wrestled with permissions and all sorts of other stuff, trying to get a simple batch file to run, with no luck.  I tried lauching the bat file directly, launching cmd.exe and calling the bat file using stin. No dice.  It seems that something on my machine was keeping an unattended process from running bat files.  This makes sense, but I was never able to pinpoint what was preventing this, so I came up with a workaround.

    I realized that since I could sucessfully run cmd.exe, and send commands to it via stin, I could just open the batch file, and send each line to cmd.exe, which is essentially the same as running a batch file itself.  This technique works great, and I thought I'd pass along the code here.

    // Get the full file path
    string strFilePath = “c:\\temp\\test.bat”;

    // Create the ProcessInfo object
    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
    psi.UseShellExecute =
    false;
    psi.RedirectStandardOutput =
    true;
    psi.RedirectStandardInput =
    true;
    psi.RedirectStandardError =
    true;
    psi.WorkingDirectory = “c:\\temp\\“;

    // Start the process
    System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);

    // Open the batch file for reading
    System.IO.StreamReader strm = System.IO.File.OpenText(strFilePath);

    // Attach the output for reading
    System.IO.StreamReader sOut = proc.StandardOutput;

    // Attach the in for writing
    System.IO.StreamWriter sIn = proc.StandardInput;

    // Write each line of the batch file to standard input
    while(strm.Peek() != -1)
    {
      sIn.WriteLine(strm.ReadLine());
    }

    strm.Close();

    // Exit CMD.EXE
    string stEchoFmt = "# {0} run successfully. Exiting";

    sIn.WriteLine(String.Format(stEchoFmt, strFilePath));
    sIn.WriteLine("EXIT");

    // Close the process
    proc.Close();

    // Read the sOut to a string.
    string results = sOut.ReadToEnd().Trim();

    // Close the io Streams;
    sIn.Close();
    sOut.Close();

    // Write out the results.
    string fmtStdOut = "<font face=courier size=0>{0}</font>";
    this.Response.Write(String.Format(fmtStdOut,results.Replace(System.Environment.NewLine, "<br>")));

    That's it!   Works like a charm! 

    -Brendan

  • New IE features I'd like to see... Grabby Scrolling

    Yesterday, I posted about a new feature of IE I'd like to see. Here's another feature I was thinking about.  This one is stolen from other applications like Adobe Acrobat.  I'm not sure the proper term for it, but I think that “Grabby Scrolling” is a good one too.

    On a typical IE page, clicking the left mouse button on anything but a link, text, image or UI control has no effect.  To me, this is a wasted UI opportunity.  Acrobat uses this space to allow the user to click and drag the page to scroll horizontally or vertically.  Why not have that functionality in IE?  Often moving the mouse to the scrollbar requires more effort than necessary.  Okay, call me lazy.  And I always forget about that wheelie thing on my mouse, so they might as well get rid of it.   Having this funtionality would allow you to scroll the current window without moving the mouse to the scrollbar. 

    -Brendan

  • New IE features I'd like to see...

    I was listening to a Dot Net Rocks show recently, and the topic of the MS IE platform's evolution came up.  They mentioned a couple of features they'd like to see in IE, like Tabbed Browsing.

    So over the weekend, I was thinking of features that I'd like to see. Now, I was trying to take a nap at the time, and must've been half asleep, because most of the ideas I came up with weren't too good.  Like “3D Browsing.“  This idea would be to break apart a web page into layers like images, advertisments, text links, and allow the user to view one or more layer at a time.  Well, not all that great of an idea, but then again, I was half asleep.

    But an idea I had that I think could work would be “Tree History.“  This would be an enancement to the back and next buttons, which would give you an option to decend branches of your history's tree.  Currently, with IE, when you click the next button, you have the option to load your history pane or go to the next history page on the stack.  Often, I find myself wanting to back up and decend a previously visited branch of my history. So, instead of this:

    Clicking my next button would give me an option to go to different branches of my history, if present, like this:

    I'd think this would be pretty easy to implement.  So easy that I'm sure it's been done before.  If you've had an idea for a new feature, post it here.

    -Brendan

  • Chris Sells makes me want to work for Microsoft

    There's a cool video on Channel 9 where Chris Sells talks about Microsoft culture and their (agile?) software development methodologies.  Wow. What a good evangelist for MS.  It's the kind of honesty that we rarely get to see in the business world. 

    I don't know about you, but I get so turned off by business marketing speak.  It really makes me want to go live and work on a farm somewhere just to get away from stupid Dilbert-esque business stuff.  But, watching this interview makes me want to pick up and move to Redmond. Not that they'd have me there, but it seems like a fun place to work.  Cool guy.  He really comes off as being down-to-earth.  Now this may be marketing in itself, just in a different package, but that's okay.   Marketing is not going to go away, so I'd rather live in a world filled with down-to-earth marketing.

    -Brendan

     

  • Send in your Off-shoring stories...

    So,

    Thinking about Off-shoring again, Dave Donaldson sent me a link to this blog post.  His post made me wonder if there are fundamental flaws in the off-shoring model.  First, I guess I need to know how off-shored engagements typically work.  My guess would be that some sort of use case / design doc is delivered to the remote team.  The remote team begins the dev phase, with frequent milestones and deliverables.  Hopefully, there's a good deal of user testing along the way.  Is this generally correct? 

    Now, if I'm right, haven't we decided that this model doesn't really work?  I mean, isn't it pretty much common knowledge these days that software can't be designed and then handed off to a team of developers, wherever they are?  What about spiral, iterative development?  What about Agile software development. Don't these models produce better software? If so, can they be integrated with offshoring?

    All this reminds me of the whole debate between self-paced and instructor-led training.   I spent a lot of my early career building systems for delivering CD-ROM and WBT training.  It all sounded great.  Just package up the knowledge and send it out there!  Yeah!  People will be way into that!

    Well, I'm afraid to say that 10 years later, I realize that it just doesn't work too well.  Nothing beats iterative, interactive learning with a human being involved as the facilitator.  A good friend of mine heads up a fortune 500's internal training department.  He's opted mainly for good old instructor-led training.  And he even once started a company focused on self-paced instruction!

    So, what does this all have to do with off-shoring?  Well, I think that the more you remove the human, hour-to-hour contact with the entire software development team, the more likely you are to fail.  Just as you can't send some instruction off into the great wide open and expect some student to get it, you can't send a bunch of requirements off to some far-off team and expect them to code it!

    I dunno.  Am I wrong?   Well, I've never been involved in an off-shored engagement, so I'm wondering if people could respond here with their stories, good or bad. 

    -Brendan

More Posts Next page »

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

MVP
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.