Home > .NET, humour, programming > Does this seem nice to you?

Does this seem nice to you?

March 31, 2009 aabs

After years of recoiling at the sight of code like this, am I supposed now to embrace it in a spirit of reconciliation?

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            dynamic blah = GetTheBlah();
            Console.WriteLine(blah);
        }

        private static dynamic GetTheBlah()
        {
            if (DateTime.Now.Millisecond % 3 == 0)
                return 0;
            else
                return "hello world!";
        }
    }
}

need to wash my hands.

Categories: .NET, humour, programming
  1. March 31, 2009 at 23:02 | #1

    Funny you should mention it. The dynamic keyword seems like the new Variant. Ah well… much like JavaScript, you don’t have to use everything!

  2. April 1, 2009 at 06:42 | #2

    No, you shouldn’t embrace that code. Nor would a hard core JavaScript/Ruby/Python/WhatEverDynamicLanguageYouWantToName developer embrace that. You can shoot yourself in the foot in any language, static or dynamic, so don’t blame bad code on what a language allows.

  3. April 1, 2009 at 08:31 | #3

    That might be an abuse of the dynamic keyword :)

  4. Alexey Baskakov
    April 1, 2009 at 15:21 | #4

    Well-typed programs can’t be blamed. A paper by Philip Wadler.

  5. April 2, 2009 at 01:01 | #5

    I’d like to have a way of yielding a compiler warning if there’s a ‘dynamic’ thing in the app! :)

  6. Dom
    April 2, 2009 at 04:51 | #6

    You can convert that to csh and make it better :-)

  7. April 3, 2009 at 12:25 | #7

    Right! And the point of static typing is to prevent what kinds of abuse?

Comments are closed.