sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Modules vs Called programs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Modules vs Called programs

    Ok I am about to embark on a long conversation with everybody.

    I am into doing procedures but they are more or less just my replacement for subroutines, coded within the main program.

    Today I downloaded a routine and it was a mainline and a module.

    So I create the module, create the service program, then create the main module then create the program.

    All fine and dandy. Alot of create this create that, bind this bind that.

    If I had of put the procedure within the main program then just compile the program it would have done the same thing and saved me alot of time.

    So now the discussion.

    a) What are the benefits for creating module/service program and main program over just coding the procedures all with the same main program?

    AND

    b) What's the difference/benefits if I create a module as opposed to a called program? (none that I see)

    Called program:
    1) I can change that called program and never have to worry about the programs that call it (save and except if I change the parms).

    2) If I use a module, don't I have to recreate/rebind all the mains if I change that module (all that extra work).

    3) in most of the environments I work in, the user nor the performance would see any difference.

    4) same amout of coding wheather it's a module or a subprogram, just extra work binding it all together.

    Please educate me then maybe I can see the benefits.

    Thnx and have a good weekend.
    Bill
    "A good friend will bail you out of jail,
    A true friend would be sitting beside you saying,
    'Wow, that was fun.'"

  • #2
    Re: Modules vs Called programs

    Well, I know where you are going because I had the same thought. Service programs and calling bound modules can be a lot of headache if you dont have some kind of change control software in place. (Which we dont. There are only two of us in this shop.)

    Anyway, I went a slightly different route. I create libraries of basic functions that rarely need changing and call them tools. For example, I have a module called DATAQTOOLS with procedures called PopDataQ, PeekDataQ, CreateDataQ, etc... which do the expected functions.

    Then in my rpg header I put a reference to the binding directory that contains just DATAQTOOLS. Now I can just do a 14 on my RPGLE and it compiles with no worries. I can easily add new procedures to DATAQTOOLS and not need to go back and recompile any old programs because they have their own copies of the procedures bound into the program.

    The only time I would need to recompile a program would be if I CHANGED a procedure in DATAQTOOLS. Thats why I try to limit these procedures to functions that stay very static.

    I created a module for handling Data Queues, User Indexes, Messages, Security, Qtemp Objects and Spool Files. Now from with my RPGLE it is very easy to move spool files around, put them on hold, create and use indexes or data queues and manipulate objects in QTEMP.

    Comment


    • #3
      Re: Modules vs Called programs

      ok....here goes nothing...

      What are the benefits for creating module/service program and main program over just coding the procedures all with the same main program?


      modules/service programs are for reusing code without having to maintain dozens of programs that use the same code. that being said...i'd NEVER bind modules separately using CRTPGM. here's why. if i have to change the module...i STILL have to recreate every program that uses that module for the change to occur...sure i didn't have to go in and retype or cut/paste the changes all over the place...but i did still have to recompile a ton of stuff.

      Binding into a service program IS the way to go. using service programs i can simply make my change to the module source, create the module and update/recreate the service program using the module...and i'm done. no need to recompile the programs (there are some minor things to consider but i digress.) remember i am giving you a simplified version...

      What's the difference/benefits if I create a module as opposed to a called program? (none that I see)

      the main difference is this. using dynamic calls (i.e. calling a separate program) is slower than a bound call. another difference. using a bound call the system "knows" where to pass the parameters without having to do the "handshake" for each call to the program/procedure. a side note: even creating a program (RPGLE that is) you ARE creating a module. when you issue the CRTBNDRPG (or using option 14 in PDM) the command creates the module in QTEMP and then issues the CRTPGM to bind the module as a callable program named...you guessed it...the module name.

      more info...when you call a program that is "bound" to a service program, the entire service program is loaded when you make the first call to a procedure in the service program with dynamic calls each program called gets loaded separately (and takes longer). the service program (if running in the same activation groupwith other situations may require additional consideration) the service program will stay loaded into memory so subsequent calls to the service program are much faster. so if you have 5 programs that use the same service program in the same activation group you only have the one time hit for loading the service program whereas with dynamic calls the program gets loaded over and over and over again (of course some of this can be mitigated by leaving *INLR off but that's still one occurance..after the calling program ends the called program goes poof...

      with all that said...you should take a look at the ILE concepts manual for more info
      there are other good resources available but you'll have to look them up
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: Modules vs Called programs

        Hi Bill:

        First see this thread:
        http://code400.com/forum/showthread.php?t=1764

        For the most part I agree with your thoughts but as was pointed out in that thread:

        Each time a program is called it takes time to load.
        A bound module is only loaded once.

        That will have a big effect in a batch program processing thousands of records (thousands of "loads" per program called).

        Using the called program in an interactive environment will have virtually no effect.

        That's my 2 lincolns
        Sorry Bill: thats my 2 maple leafs

        GLS
        Last edited by GLS400; April 4th, 2008, 02:51 PM.
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Modules vs Called programs

          I don't really want to reopen this can of worms, I'll probably just need a simple answer like a 'yes' or a 'no' but I might be wrong - that happens.

          So I have a program that I'm writing and there is a possibility that it will need to be called from an already existing program that is not written in an ILE way. My question is this....

          If I make my program a service program then can the other program be compile using CRTBNDRPG or would the program have to be compiled into a module with the service program and then compiled into a program?

          I'm trying to make this as easy as possible. I would like to make it a service program that would be nice and callable with some parameters as opposed to a callable program. I'm trying to fight for ILE concepts in a non-ILE shop so if I can implement this in ILE fashion without ruffling too many feathers with the non-ILE guys that would be great.
          Your future President
          Bryce

          ---------------------------------------------
          http://www.bravobryce.com

          Comment


          • #6
            Re: Modules vs Called programs

            Originally posted by bryce4president View Post
            ...program that is not written in an ILE way...
            What does that mean?
            "Time passes, but sometimes it beats the <crap> out of you as it goes."

            Comment


            • #7
              Re: Modules vs Called programs

              Meaning that it had no intention of being compiled as a module and bound to something else. Now I know that it isn't REALLY anything major, but to a non-ILE style programmer? I just want my program to be callable with parameters and if at all possible not have to have them worry about doing too much on their end to accommodate. Would they need to include the binding directory if they want to use the service program? I'm still working out a few kinks in my own understanding of it all...
              Your future President
              Bryce

              ---------------------------------------------
              http://www.bravobryce.com

              Comment


              • #8
                Re: Modules vs Called programs

                Bryce,
                You can call an ILE program from an OPM program and the other way round but you can not call a procedure in a service program from an OPM program if this is what you mean.
                Philippe

                Comment


                • #9
                  Re: Modules vs Called programs

                  Originally posted by Mercury View Post
                  Bryce,
                  You can call an ILE program from an OPM program and the other way round but you can not call a procedure in a service program from an OPM program if this is what you mean.
                  BINGO...if there's no real changes to be made to the RPG III OPM stuff why not just do a CVTRPGSRC to convert it to RPG IV then you can use the service program, otherwise as Mercury says you'll have to make it a stand-alone program and just do calls to it.
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: Modules vs Called programs

                    The program that is going to call it is in RPG IV. After he makes the change to call the service program does the program need to be compiled with the binding directory or anything else? Any need to copy the prototype of the procedure?
                    Your future President
                    Bryce

                    ---------------------------------------------
                    http://www.bravobryce.com

                    Comment


                    • #11
                      Re: Modules vs Called programs

                      Originally posted by bryce4president View Post
                      The program that is going to call it is in RPG IV. After he makes the change to call the service program does the program need to be compiled with the binding directory or anything else? Any need to copy the prototype of the procedure?
                      not unless the parameters have been changed. if the service program runs in *CALLER activation group and the calling program is running in the DFTACTGRP they will have to end the job (i.e. sign off if interactive) to pick up the changed service program) but the answer is no...unless as i said the procedure's parms have changed.
                      I'm not anti-social, I just don't like people -Tommy Holden

                      Comment


                      • #12
                        Re: Modules vs Called programs

                        Bryce, I've been reading lately on some of the forums where you are getting into this as well. Trust me, after you get some experience using service programs, you will live and swear by them.


                        One of the least talked about advantages of using service programs is that of change management. The number of programs you have to check out, and the number of programs that ultimately have to be changed, recompiled, and tested, can be reduced to 1 when you utilize service programs.
                        Michael Catalani
                        IS Director, eCommerce & Web Development
                        Acceptance Insurance Corporation
                        www.AcceptanceInsurance.com
                        www.ProvatoSys.com

                        Comment


                        • #13
                          Re: Modules vs Called programs

                          Originally posted by MichaelCatalani View Post
                          Bryce, I've been reading lately on some of the forums where you are getting into this as well. Trust me, after you get some experience using service programs, you will live and swear by them.


                          One of the least talked about advantages of using service programs is that of change management. The number of programs you have to check out, and the number of programs that ultimately have to be changed, recompiled, and tested, can be reduced to 1 when you utilize service programs.
                          i talk about it all the time see post #3...
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment


                          • #14
                            Re: Modules vs Called programs

                            Great great information guys. Its exactly what I needed. I'm just gonna create the service program out of it and let the other guy call it as he needs. I will also then need to call it from another program myself. I really like the idea of modularizing, its what I grew up on. Now its a matter of getting others to program this way... pssshhhh.
                            Your future President
                            Bryce

                            ---------------------------------------------
                            http://www.bravobryce.com

                            Comment


                            • #15
                              Re: Modules vs Called programs

                              Originally posted by soup_dog View Post
                              Well, I know where you are going because I had the same thought. Service programs and calling bound modules can be a lot of headache if you dont have some kind of change control software in place. (Which we dont. There are only two of us in this shop.)

                              Anyway, I went a slightly different route. I create libraries of basic functions that rarely need changing and call them tools. For example, I have a module called DATAQTOOLS with procedures called PopDataQ, PeekDataQ, CreateDataQ, etc... which do the expected functions.

                              Then in my rpg header I put a reference to the binding directory that contains just DATAQTOOLS. Now I can just do a 14 on my RPGLE and it compiles with no worries. I can easily add new procedures to DATAQTOOLS and not need to go back and recompile any old programs because they have their own copies of the procedures bound into the program.

                              The only time I would need to recompile a program would be if I CHANGED a procedure in DATAQTOOLS. Thats why I try to limit these procedures to functions that stay very static.

                              I created a module for handling Data Queues, User Indexes, Messages, Security, Qtemp Objects and Spool Files. Now from with my RPGLE it is very easy to move spool files around, put them on hold, create and use indexes or data queues and manipulate objects in QTEMP.
                              Hi,

                              I have a question here. I am foraying into ILE for the first time so please excuse my noobiness.

                              I have 3 modules combined into a service program which in turn is listed in a binder directory. Then I create a simple RPG program which has prototypes of the procedures in the 3 modules and uses these procedures to do some stuff. While compiling, I only specified the binding directory and not the modules or service program directly. I am calling the procedures using CALLP (I guess there is no other way, please confirm) in the program.

                              As quoted by @soup_dog, If I edited the code inside any of the modules, do I have to do all of the steps below:
                              1. Recompile the module (Ofcourse)
                              2. Recompile the service program
                              4. Recompile the program.

                              Please advice?

                              Also, if I were to add a new module into the service program, I would presume that I will have to set PGMLVL(*PRV) in the BND file I used to compile the service program and then create a new STRPGMEXP with the new procedures from the new modules and then recompile the service program and that's it. I can use the same binder directory into another program without having to ever touch the first program I created. Please confirm?

                              Thanks in advance.


                              Regards,
                              Sriram

                              Comment

                              Working...
                              X