I've bookmarked that link to Scott's presentation. I don't see it among my 50+ other links, most of which I've read. I've even put it in my "RPG Tips" folder as well as my Stored Procedures" and "Binding Programs" folders in my "bookmarks toolbar". Now if I can get a chance to really study it rather than just make sure I haven't already read it. It, as you imply, looks good and what might be helpful.
Yes, a few is more than 1. Here, though, the code doesn't get changed until there is an issue with it and code that works isn't considered to have issue with it. At least in the minds of others. It's a bit difficult for me to explain. It's sort of like Scott's by-line. "there are 10 types of people in the world..." and I paraphrase, those who get the joke and those who don't."
I would love to have everyone I work with agree that thinking along the lines of enhancing as we go. The problem is a refusal to believe that it's an enhancement when it's so difficult to understand. And it is difficult to grasp the concept for a lot of long time RPG programmers. And even if that difficulty is overcome, then there is the issue of when to make the switch. If a section of code "works", but is able to be switched out for a working procedure, then even if the switch is made with the confidence I would have, the code must be tested twelve ways to Sunday before it's released into the Live environment. The overhead is staggering.
I've been beating that horse for a number of years and it doesn't seem to want to move.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Charles Wilt
Sent: Friday, February 03, 2017 12:40 PM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Procedure Examples VR7.1
On Fri, Feb 3, 2017 at 9:54 AM, Duane Scott <dscott@xxxxxxxxxxx> wrote:
getting just the name or phone number of the main contact for that
customer record may not be necessary in but a few. Would a separate
procedure be written just to grab the contact from customer record?
Is a few more than 1?
So the code required is reusable and rule #1 1. everything that can be reused, is an external procedure/function in an service program
There's your answer. ;)
Consider the following scenario
You've got customer contact info in customer master table. You build a CUSTOMER_GetContact().
Next year, it's decided that you need to have more than one contact per customer. It's real easy to move the existing contact to a new CUSTOMER_CONTACTS table and modify CUSTOMER_GetContact() to accept an optional CONTACT_TYPE parameter. Without it, it returns the MAIN contact.
But you can also request CONTACT_TYPE = AP.
You don't have to modify or even recompile anything existing that uses CUSTOMER_GetContact().
Honestly, code doesn't have to be re-used currently to be placed in a service program. Placing it in a service program to start makes it reusable in the future. Ideally all your business logic should be in a service program.
Yeah, it's not going to happen overnight with an existing system. But when adding enhancements (particularly around new tables) You should be thinking about how to enable re-use of the new business logic. When modifying existing logic, particularly logic that's been copied and pasted into multiple places, take the time to figure out how to pull it out and into a service program.
Take my new CUSTOMER_CONTRACTS table...I'd have at least
CUSTOMER_ListContacts()
CUSTOMER_CreateContact()
CUSTOMER_UpdateContact()
CUSTOMER_DeleteContact()
The logic to validate a contact (phone number, address, email, ect) would be in an procedure internal to the CUSTOMER service program and called by
CUSTOMER_CreateContact() & CUSTOMER_UpdateContact().
An hey next year, when it's decided you need to allow the same contact info to be used by multiple customers...it's lots easier to move the contact info into a new CONTACTS table and the old CUSTOMER_CONTACTS becomes a simple association table with just CUSTOMER_ID, CONTACT_ID, CONTACT_TYPE.
If you haven't seen one of Scott's presentations, take a look at this one.
http://www.scottklement.com/presentations/Pattern%20to%20Good%20ILE%20with%20RPG.pdf
Charles
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
CONFIDENTIALITY NOTICE: This electronic message transmission is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. If you have received this transmission, but are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this e-mail in error, please contact NALC Health Benefit Plan at 703-729-4677 and delete and destroy the original message and all copies
As an Amazon Associate we earn from qualifying purchases.