|
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
As an Amazon Associate we earn from qualifying purchases.
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.