ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

RPG Free Coding Standards

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

  • RPG Free Coding Standards

    Hi All, My shop has recently written formal coding standards for RPG Free. To the man, everyone dislikes what has been presented. And of course as one might expect, each programmer has a different opinion as to which items need to be changed. The only way for us to get these changed is to have a consensus among the staff. Because each programmer has a different opinion, I would like to reach out to this group for anyone that would be willing to share with me a formal copy of their shops coding standards. We are currently running on V5.1 of the OS. Soon to be upgraded to 7.0. Please help. Thank you.

  • #2
    Re: RPG Free Coding Standards

    I don't have a formal shop document... but here is what I usually go by...

    I almost always use the extended variable naming format, even if I don't need it, because it makes the variable declarations appear uniformed... such as...

    Code:
         D y               s             10i 0 inz(0)
         D availableQuantity...
         D                 s              9s 0
         D job2AvailableQuantity...
         D                 s              9s 0
         D saverrn...
         D                 s              4s 0
         D saverrn2...
         D                 s              4s 0
    I use long names, a lot. Why not? I want my code to read like a book.

    I always use 2 spaces for my indent when working with RPG. This is because if you use 4, then the 80 column limit can be even more of a pain in the **s.

    Just a couple of things off the top of my head there.
    Last edited by bryce4president; August 31, 2012, 01:14 PM. Reason: typos and consistency
    Your future President
    Bryce

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

    Comment


    • #3
      Re: RPG Free Coding Standards

      Hi mytruck_82:

      Nice style guide here:

      and I hear the guy that wrote it is a really really nice guy.

      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: RPG Free Coding Standards

        Thank you for your reply. I am hoping to find some examples of qualified data names. We are up to coding 24 plus character data names. Too much in my opinion. Thank you again for your reply.

        Comment


        • #5
          Re: RPG Free Coding Standards

          I was digging through a program today and found the following code (it reminded me of this thread so I had to post):

          Code:
          //  Get the Order Header...                         
                     ordkey.company# = comp#  ;               
                     ordkey.order#   = order#    ;            
                     ordkey.ship#    = ship#     ;            
           //                                                 
                            chain  %kds(ordkey)    oordhr  ;  
                            if        %found              ;   
                                                              
                      ordnon = oordn                 ;        
                      oshpnn = oshpn         ;                
              //                                              
                setordexport(comp#:order#:ship#)   ;          
             //                                               
            // Get the Customers Trade Partner Id             
            //                                                
                  edcstedds = getedcstedi(ocomp:ocustn)    ;  
          //                                           
                if    edcstedds.cecust <> *blanks   ;  
                 cftradep = edcstedds.cetpart  ;       
                 tradepartner = edcstedds.cetpart  ;   
                   tradep = edcstedds.cetpart  ;       
          //                                           
                               bsn01 = '00'     ;
          (no lie, this is how it's formatted)
          I cried. It works, but wow is it hard to read. I used the same link GLS posted to learn to format my /free code, and tbh it's some of the most legible code I've ever seen.

          Comment


          • #6
            Re: RPG Free Coding Standards

            That is just crazy! I am going to have to insert a random number of blanks at the end of each free statement prior to the semi-colon... doh!

            Comment


            • #7
              Re: RPG Free Coding Standards

              i got a dizzy feeling just looking at that...and i just ate lunch...i hope i don't end up talking to Ralf through the "Great White Megaphone" after that!!!
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: RPG Free Coding Standards

                It takes work to make /free ugly....
                I hope the guy who did that still work there..
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: RPG Free Coding Standards

                  Originally posted by ARobb73 View Post
                  I was digging through a program today and found the following code (it reminded me of this thread so I had to post):

                  Code:
                  //  Get the Order Header...                         
                             ordkey.company# = comp#  ;               
                             ordkey.order#   = order#    ;            
                             ordkey.ship#    = ship#     ;            
                   //                                                 
                                    chain  %kds(ordkey)    oordhr  ;  
                                    if        %found              ;   
                                                                      
                              ordnon = oordn                 ;        
                              oshpnn = oshpn         ;                
                      //                                              
                        setordexport(comp#:order#:ship#)   ;          
                     //                                               
                    // Get the Customers Trade Partner Id             
                    //                                                
                          edcstedds = getedcstedi(ocomp:ocustn)    ;  
                  //                                           
                        if    edcstedds.cecust <> *blanks   ;  
                         cftradep = edcstedds.cetpart  ;       
                         tradepartner = edcstedds.cetpart  ;   
                           tradep = edcstedds.cetpart  ;       
                  //                                           
                                       bsn01 = '00'     ;
                  (no lie, this is how it's formatted)
                  I cried. It works, but wow is it hard to read.

                  Well, I have a feeling I know what he was *trying* to do. Years ago when /free first came out, I was trying to see if the ";" characters would look better separated a bit from the line of code. The result is the same as what you see above. It *might* actually look better in one line of code, but when you have many lines, all with different lengths, it will yield the same effect as watching the Blair Witch Project.

                  Also, %kds........yuck!



                  I used the same link GLS posted to learn to format my /free code, and tbh it's some of the most legible code I've ever seen.
                  That dude can be a complete douchenozzle at times, but usually he's ok.
                  Michael Catalani
                  IS Director, eCommerce & Web Development
                  Acceptance Insurance Corporation
                  www.AcceptanceInsurance.com
                  www.ProvatoSys.com

                  Comment


                  • #10
                    Re: RPG Free Coding Standards

                    If I could get one thing removed from our standards it would be the qualified data structures. i.e. RFM0080_I DS Likerec(RFM0080)

                    Chain ( P_FML0081.ConId )
                    FM0080 RFM0080_I;
                    Why do RFM0080_I; ???? This looks like COBOL from 1982. This is a physical file. When you do it with a display file it get worse. Thank you, G

                    Comment

                    Working...
                    X