in reply to Re: Perl editor idea
in thread Perl editor idea

To some extent, the modularization is what's preventing me from doing all the work with a given variable at once, which is why I need numerous, identical comments in various parts of the script, to remind me of interdependencies of certain variables.

What? The whole idea of a properly modularized program is that you don't have as many interdependencies among variables or among different parts of the code.

What needs to be done, and which can be done without objects if desired, is to have the program separated by some opaque barriers and to group truly structured information into real data structures.



Christopher E. Stith

Replies are listed 'Best First'.
Re: Re: Re: Perl editor idea
by Wassercrats (Initiate) on Jan 16, 2004 at 00:53 UTC
    There seems to be three ways I could handle this.
    • When I have to change a variable, check everything else that might require that variable to be changed and make all the changes in a relatively confined area. Only one comment on the use of the variable would be needed.
    • Use subroutines for major divisions of the script and when they would make the script shorter, with comments to avoid problems with variable interdependencies. This is what I'm doing.
    • Use subroutines or objects to avoid problems with variable interdependencies, in addition to subroutines for the major, parent divisions. This is what people are suggesting.

    In my case, using comments rather than subroutines or objects for my array triplet (actually, I just realized it's a quadruplet) avoids problems with variable interdependencies just as well. It also makes my code easier to follow and understand, run faster, and easier to develop (especially for me).

    Yesterday, I forgot which of those arrays had been added to by a certain point in the script, and I wanted to splice those that were added to. Rather than permanently using a splicing routine that checks the length of the arrays, I used such a routine as a debugging tool only, found out which arrays had been added to by that point, then permanently added lines to splice only the arrays that would need splicing at that point. In addition to preventing having to dig deeper into the code to understand it, my unconditional splicing makes apparent which arrays had been assigned to by that point in the code, which could be useful for future maintenance.

      If it makes it easier for you, then that's a good thing. I'm having a hard time understanding how having four arrays which are closely related is better than having a hash of four arrays.

      Of course, without actually seeing an example of what your code is doing, I can only respomd in the most general of terms. I may not even be really clear on just what you do have. The way I understand things from your descriptions, though, there would be many things I would do that would make it easier for my own understanding if I were doing the coding. You and I may just think in different ways.



      Christopher E. Stith