Consistency? I try very hard to use consistent names in my code.
For example, for almost every loop I code, I try to use Idx as the counter unless I need something very specific like idxCust or nested loops. Local variables in a procedure mean I never have to worry about stepping on globals.
Your subroutine may use only globals now, but next month???
Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of Richard Schoen <Richard.Schoen@xxxxxxxxxxxxxxx>
Sent: Monday, February 5, 2018 9:09 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: What is a Modern RPG Programmer???
I was thinking on this one a bit and aren't sub-procedures main functions where you pass parms in and get info back.
Much like in other programming I do, I like to think of them as a black box, especially when used across applications.
If a sub-procedure for some reason uses all the global program variables and is simply being used to encapsulate some looping logic or something similar, why not use a subroutine instead ?
Just thinking out loud on this.
I don't do a ton of RPG coding any more so a few example use-cases would be good to hear about.
Regards,
Richard Schoen
Director of Document Management
e. richard.schoen@xxxxxxxxxxxxxxx
p. 952.486.6802
w. helpsystems.com
----------------------------------------------------------------------
message: 1
date: Mon, 5 Feb 2018 11:23:02 -0500
from: Jon Paris <jon.paris@xxxxxxxxxxxxxx>
subject: Re: What is a Modern RPG Programmer???
I have to agree with Rob on this.
My policy is that if you want to use a subprocedure go ahead. If you want to use a subroutine then you need to explain to me what benefits it offers and why you are convinced that it will never need parameters or a return value.
Future protection - I don't want my programmers producing future relics.
Jon Paris
www.partner400.com
Partner400 - Your partner in iSeries education
www.partner400.com
If you are looking for the very best in IBM i* Education, Consulting and Mentoring services you have come to the right place! We are dedicated to helping our ...
www.SystemiDeveloper.com
System i Developer - Home Page
www.systemideveloper.com
Modernize at the RPG & DB2 Summit. i can… you can, too! Refresh your skills at the RPG & DB2 Summit and feel the thrill of delivering innovative software solutions ...
On Feb 5, 2018, at 10:57 AM, Rob Berendt <rob@xxxxxxxxx> wrote:
John Erps,
I didn't say never use a subroutine. I said that I personally went
hardcore on only using subprocedures for a year. And stated my reason.
You can see that below in the thread. Once I broke the habit of
falling back to what was easy and comfortable I used subroutines where
appropriate. I really thought I was quite clear on that.
One thing to keep in mind is to always think of the future.
What may be a subroutine in an existing program could evolve.
- First into a subprocedure
- Next moved out of the main program into a service program.
- Then someone could create a UDF from that service program
subprocedure
- That UDF could be called by SQL with stuff like Select item_number,
onhand(item_number)...
- That UDF could be imbedded into an SQL view Create view Item_user
as (select item_number, onhand(item_number)...
and thus making user queries easier.
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
http://www.dekko.com/wp-content/uploads/2016/01/design-dev.png
Dekko | Innovative Leader Providing Manufacturing Solutions
www.dekko.com
Dekko is your trusted electrical solutions partner focused on power and data systems, LED lighting solutions, and electrical components and assemblies.
As an Amazon Associate we earn from qualifying purchases.