The Human Brain is not Compatible with Recursive Methods.

Just got through a session programming some recursive xml parsing and component display functions. Finally got it going right and that felt great. But in the process I found myself staring into space and starting to drool several times. I gained some real empathy for the Flash Player when it gets stuck in one of those 256 level of recursion loops. The brain just locks up. I thought this summed it up pretty well:

This entry was posted in Flash, General. Bookmark the permalink.

6 Responses to The Human Brain is not Compatible with Recursive Methods.

  1. JesterXL says:

    You can always tell when a programmer is burnt out: they start designing things.

  2. Gerard says:

    Hi Keith,
    Thanks for sharing that, I thought that I was the only person
    amidst all thos brilliant programmers that got lost sometimes.

    PS I don’t start designing things I start e bottle of red when it’s late enough!

    PPSS Got this error message now:
    Fatal error: Nesting level too deep – recursive dependency? in /home/bit-101/public_html/blog/wp-includes/kses.php on line 377

  3. Nicola says:

    Recursion some time is not good. An iterative method can help (but some time is so difficult to make it the right way).
    Good luck

  4. stone says:

    It would be better not to have focus on the OK button.
    Changing the brain context might reset your hardware.
    The alert is too long and is resource consuming (remember that yor brain is in a loop).

    Useful messages to think about something else and free up some memory would be:

    1. “Free nudity?” [yes|no]
    2. “See bikinis?” [yes|no]
    3. “Cancel this thought?” [yes|no]

    Bye.

  5. Squee-D says:

    I solidly suggest that when you code recursive methods, you ignore the recursion 🙂

    Think about what is passed to the function and what it will do with it. when you call the function from within itself, think of it as a call to some other function. That stops you thinking down a tree of recursion, you are simply writing a function that handles something, and at worst handles a part of that something with another function call.

    Finally make sure your escape condition is tight. There should be some way of avoiding a recursive call that’s reliable..

    EG:

    function a() {
    if (condition) { // make sure the condition is likely to get you out of the recursion at some point
    return a();
    } else {
    return null;
    }
    }

  6. Petit says:

    Thanks for admitting to the exhaustive brain looping.
    I always found, that whenever I force myself into recursion, my head starts to spin.

    Squee-D: You’re right of course, but I find it hard to think of the function calling itself as “some other function”.

    On another note, although recursion may look “elegant”, it’s not always effective. I have a hard time finding a case that you can only solve with recursion, and I prefer “transparent” before “elegant”. Teaching programming may have damaged my brain 🙂

Leave a Reply