in reply to Re^3: Speeding up RecDesent parser for Perl Code
in thread Speeding up RecDesent parser for Perl Code

Refactored it 2 times until now. But it is the main modul of an GUI-IDE with 2 years of work behind it and has about 130 subs (not to mention the anonymus ones). Futher refactoring would be serious work, that I have currently no time for.

Andre
  • Comment on Re^4: Speeding up RecDesent parser for Perl Code

Replies are listed 'Best First'.
Re^5: Speeding up RecDesent parser for Perl Code
by merlyn (Sage) on Sep 07, 2006 at 21:15 UTC
      None and dont know the code coverage either. I think the perl modul tests cant be quite transfered to GUI programs, because most of those functions are callbacks from button and other controls and their behaviour depends on the current situation in the application and in some cases I can't test because I simply cant generate the neccesary case without actually pressing a mouse button (for example). Theire are even cases where the user can enter a Perl Regular Expression (or a sort function) that have to be evaled carefully. I know myself that the testing is a necesary process, but I think that automated testing mechanism create a false confidence, cause you never know what the user is going to to.

      Andre
        Ahh, so this is why you refactor. Move your model and controller code out and away from your view code, and you'll be able to test each independently.

        The more you describe your system, the more I wonder how much time I would waste in maintenance coming in after you if you had left. It sounds like a nightmare.

        I got this quote off a mailing list a short time ago. I think it fits:

        it was the sort of code that made grown men cry.

        He saw it and knew then that his life would never be the same. Gone forever were the nights spent with friends in the pursuit of manly activities, replaced with curling under a blanket with a bottle of cheap vodka mourning a more innocent age, an age before his bad code deflowering. As he looked at the code, he resigned himself to the therapy, the drugs, the late-night waking-up-from-nightmares-drenched-in-sweat-and-screaming that lay ahead, and started contemplating the only other avenue open to him now -- an easier, so much easier avenue. If only suicide was not an unforgivable sin in the Catholic church ...

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

Re^5: Speeding up RecDesent parser for Perl Code
by aufflick (Deacon) on Sep 11, 2006 at 01:41 UTC
    Not to deprecate merlyn's excellent advice, but if you purely want to reduce the number of lines in the module to make it a bit easier to deal with, why not just cut the file into 5 or so separate files and include them all in the one master file.

    Hardly the "good design", but it might be a way to start. You could make the separate files contain conceptually separate code (even though to the compiler there would be no difference). These files could then be the basis for some real refactoring later.