ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Procedures - What do you use within them?

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

  • Procedures - What do you use within them?

    What are your standards/best practices when using procedures? Do you use subroutines or sub-procedures in them? Do your procedures have display files or do you create a program when display files are needed?

    Thanks for feeding my curiosity!

  • #2
    Re: Procedures - What do you use within them?

    I never use sub routines.
    Procedures do use other Procedures (sometimes)

    I create programs (that have procedures) that use displays.

    More importantly for me is I create/add to service programs when ever I can. If it is remotely possible for a procedure to be ever used by another thing, then in it goes into a service program.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Procedures - What do you use within them?

      Hi Chandrak311:

      I also only use sub-procedures. By doing so I can take advantage of the return parm....
      Code:
          if MyProc()
            do_stuff
          EndIf
      I generally do display file processing in the main-line of the program. I do file I/O in the sub-procedures
      Code:
          Load_subfile()
          get_myfile1()
          write_myfile1()
          write_myfile2()
      Best of Luck
      GLS
      The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

      Comment


      • #4
        Re: Procedures - What do you use within them?

        My answers are the same as DeadManWalks except I do have some procedures that use subroutines within them.

        Comment


        • #5
          Re: Procedures - What do you use within them?

          Originally posted by Chandrak311
          What are your standards/best practices when using procedures? Do you use subroutines or sub-procedures in them? Do your procedures have display files or do you create a program when display files are needed?
          It really depends on what the program does.

          Subprocedures that call other subprocedures is very commonplace... but it's not always necessary. It depends on what the routine does.

          It's very rare that I would use a subroutine inside a subprocedure -- typically, if I need this, I start thinking that my subprocedure needs to be broken up further into smaller subprocedures. However, there have been occasions over the past 17 yeras where a subroutine was a better fit. It's unusual, but it happens sometimes.

          I don't completely understand the bit about display files. Since programs are made up of procedures, if you put them in a program, you are always also putting them in a procedure. (it may be a main procedure instead of a subprocedure -- but it's still a procedure.) Maybe you meant to ask if I put my display files in service programs (vs. programs)? If so, I typically put display files in program objects. It's very important to me to put my display logic (all of the program logic needed to display a screen) in a separate place from my business logic (which implements the rules of the business, how data is stored, etc). So I typically implement the business logic as a set of reusable routines and put them in a service program, and then I code my display logic in a program and call the business logic from there. However, sometimes (for various reasons) I will adhere strictly to the MVC paradigm where the business logic (model), display logic (view) and control logic (controller) are distinctly separate pieces. In that case, I often put the display logic in one service program, the business logic in a separate service program, and the controller logic in the program object.

          But, it really depends on what I'm doing... what the purpose of the program is. My philosophy is that almost all of the tools we have available to us are useful for one thing or another. I try very hard to use the most elegant tool for each individual situation. I think it's foolish to say "always do XXX" or "never do YYY", because you're limiting yourself that way.

          Comment


          • #6
            Re: Procedures - What do you use within them?

            Originally posted by Scott Klement View Post
            It really depends on what the program does.

            Subprocedures that call other subprocedures is very commonplace... but it's not always necessary. It depends on what the routine does.

            It's very rare that I would use a subroutine inside a subprocedure -- typically, if I need this, I start thinking that my subprocedure needs to be broken up further into smaller subprocedures. However, there have been occasions over the past 17 yeras where a subroutine was a better fit. It's unusual, but it happens sometimes.

            I don't completely understand the bit about display files. Since programs are made up of procedures, if you put them in a program, you are always also putting them in a procedure. (it may be a main procedure instead of a subprocedure -- but it's still a procedure.) Maybe you meant to ask if I put my display files in service programs (vs. programs)? If so, I typically put display files in program objects. It's very important to me to put my display logic (all of the program logic needed to display a screen) in a separate place from my business logic (which implements the rules of the business, how data is stored, etc). So I typically implement the business logic as a set of reusable routines and put them in a service program, and then I code my display logic in a program and call the business logic from there. However, sometimes (for various reasons) I will adhere strictly to the MVC paradigm where the business logic (model), display logic (view) and control logic (controller) are distinctly separate pieces. In that case, I often put the display logic in one service program, the business logic in a separate service program, and the controller logic in the program object.

            But, it really depends on what I'm doing... what the purpose of the program is. My philosophy is that almost all of the tools we have available to us are useful for one thing or another. I try very hard to use the most elegant tool for each individual situation. I think it's foolish to say "always do XXX" or "never do YYY", because you're limiting yourself that way.
            Ho Scott
            as i was interested to your tecnique (keep separated display logic from business logic) could you post some SCRUD (Search, create, Read, update and delete) program's example or could yuo suggest some links to learn you tecniche ?

            Thanks in advance

            Comment


            • #7
              Re: Procedures - What do you use within them?

              Here's the handout to a talk I give on that subject:

              Comment

              Working...
              X