Better String Input Handling

code, humor 0 comments suggest edit

I’ve been relatively quiet on my blog lately in part because of all the work on ASP.NET MVC. However, the ASP.NET team is a relatively small team so we often are required to work on multiple features at the same time. So part of the reason I’ve been so busy is that while we were wrapping up ASP.NET MVC, I was also busy working on a core .NET Framework feature we plan to get into the next version (it was a feature that originated with our team, but we realized it belongs in the BCL).

The goal of the feature is to help deal with the very common task of handling string input. In many cases, the point is to convert the input into another type, such as an int or float. However, how do you deal with the fact that the string might not be convertible to the other type.

We realized we needed a type to handle this situation. A type that would represent the situation after the user has submitted input, but before you attempt the conversion. At this point, you have a string or another type.

clip_image004_thumb

For more details on the StringOr<T> Community Technology Preview (CTP), please see details on lead developer Eilon Lipton’s Blog (he’s a big fan of cats as you can see). He provides source code and unit tests for download. As always, please do provide feedback as your feedback is extremely important in helping shape this nascent technology.

Tags: framework , .net

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

19 responses

  1. Avatar for Burak
    Burak March 31st, 2009

    Is it a feature of .NET April 1 Preview? :P

  2. Avatar for grega g
    grega g March 31st, 2009

    i hope that's an April's fool joke.

  3. Avatar for Bryan
    Bryan March 31st, 2009

    I really really hate this day. Thanks for wasting my time.

  4. Avatar for Patrik
    Patrik March 31st, 2009

    First I thought "WTF", but then I realized that it is April 1:st today. :-)

  5. Avatar for tawani
    tawani March 31st, 2009

    This is BS. This is the test you want to perform:
    StringOr<int> userInput = "abc123";
    Assert.AreEqual(123, userInput.OtherValue);

  6. Avatar for Jack
    Jack March 31st, 2009

    I liked this story than the 'Warner Bros acquires the Pirate Bay'. It's our geek type joke, a good one. Thanks Phil!

  7. Avatar for Michael D. Hall
    Michael D. Hall March 31st, 2009

    Well played sir, well played.

  8. Avatar for Neil barnwell
    Neil barnwell March 31st, 2009

    It seems a bunch of MS guys have teamed up to play this trick together, hoping that we'd fall for it. This is at least the 3rd post today about StringOr<T> I've seen.
    Thing is, joke or not, I bet there are real StringOr<T> implementations out there in the world...

  9. Avatar for alexandrul.ct
    alexandrul.ct March 31st, 2009

    Fine joke and nice ideea.

  10. Avatar for Darren Kopp
    Darren Kopp March 31st, 2009

    should have just said in v4 strings are mutable and everyone's jaws would have dropped.

  11. Avatar for Walter
    Walter March 31st, 2009

    I checked the blog just to see what the April Fools joke would be today. It was a little over my head, but it seems the fan base liked it!

  12. Avatar for Chris S
    Chris S March 31st, 2009

    April Tool'd

  13. Avatar for haacked
    haacked March 31st, 2009

    StringOr<WTF>

  14. Avatar for Raguraman
    Raguraman March 31st, 2009

    Wow !!! What a Plan !!!
    You all got me.

  15. Avatar for Andy
    Andy April 1st, 2009

    Oh my god, you can even joke with these things...
    A real NERD joke.

  16. Avatar for Jack
    Jack April 1st, 2009

    It's April 2nd now, can you tell me is it a joke or not?

  17. Avatar for RussellH
    RussellH April 1st, 2009

    Was this the answer to my question about exception handling in the Nerd Dinner app? It was an April Fools joke?

  18. Avatar for C.T.
    C.T. April 2nd, 2009

    i felt this tech is some difficult to understand for me before i read the comments.

  19. Avatar for rpgkaiser
    rpgkaiser April 6th, 2009

    Hello! MVC is a great product (or tech, whatever), but is annoying the kind of interaction we most forced to deal with. I mean the mass use of HTML helper methods instead of the extremely most pleasure component based approach. I know this is a remarkable work to do in order to enable this design pattern in MVC, but in my opinion, while this limitation exist, MVC will be a downgrade compared to WebForm, in term of design capabilities and useability.