× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



David,

IMHO, I think a little of both. I break logic up into logical functions or tasks and create procedures for each task. This keeps the mainline of the program much smaller. With the use of descriptive procedure names the mainline is almost like reading a description of what is happening. The more I code this way the more I like it.

Where I would take issue with what you are doing is in the use of global variables. As has been mentioned in many articles on RPG coding practices and many posts to this list it is preferable to use local variables in procedures and pass them the information needed to perform their task. This makes debugging and code changes much easier as you know the scope of variables is only within that procedure.

Just my $.02.

Rick

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Monday, March 01, 2010 4:44 AM
To: RPG programming on the IBM i / System i
Subject: More on RPG style

Hi,

I tend to divide my code into subprocedures in a program just to improve readability, even when there is very little risk of that subprocedure being called from anywhere else. Each subprocedure will correspond to a specific task executed by the program.

Eg,

/FREE

IF not doThis ( )
RETURN

ENDIF;

IF NOT DoThat ( )
RETURN

ENDIF;

/END-FREE

In these cases I will use global variables unless not possible. That leaves me with a load of one line prototype declarations in my code :

D doThis PR
D doThat PR

I've just discovered that this style seems to annoy at least one programmer who prefers to see all the code in one main procedure and does not like to see all those PR's PI's and returns, etc. Rather embarassing.

Am I justified in coding in this way or am I wrongly using subprocedures?

Privileged and Confidential. This e-mail, and any attachments there to, is intended only for use by the addressee(s) named herein and may contain privileged or confidential information. If you have received this e-mail in error, please notify me immediately by a return e-mail and delete this e-mail. You are hereby notified that any dissemination, distribution or copying of this e-mail and/or any attachments thereto, is strictly prohibited.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.