Home > AS/400 Tips > iSeries administrator tips > System i modularization -- part 2
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

System i modularization -- part 2


Ron Turull
03.13.2007
Rating: --- (out of 5)


iSeries news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Modularization is key to reaping the benefits of ILE. It is the major factor in cutting development time and increasing programmer productivity – the more effective the modularization, the more productive the programming staff. But it's important to arm yourself with a reliable method when modularizing your apps. In part 1,, we discussed the first few tips. Let's now get into the next couple, which will include some code examples.

More Information

Keep procedure interfaces simple and pithy

The biggest contributor to a complicated interface (i.e., a long complicated parameter list) is usually a complicated procedure with too many options and permutations. Keep it simple. Don't try to do too much with one procedure. Use multiple procedures instead with each procedure having one or two specific purposes.

For example, don't create a single procedure ConvertCase that converts to uppercase and to lowercase depending on the value of one of the parameters. Instead, create two separate procedures, one to convert strictly to uppercase and the other to convert strictly to lowercase. Not only does this simplify the procedure interface, it also makes the calling programs more readable and self-documenting (instead of seeing ConvertCase, you see either ToUpper or ToLower).

In situations where you have to have a long parameter list, you should consider "packaging" related parameters into a single data structure. This does two things:

1. It shortens the parameter list and makes the procedure interface less complicated.

2. Calls to the procedure will be faster because of fewer parameters.

To simplify using a procedure with a data structure parameter, set up a "template" data structure in an include file (i.e., a /Copy source member), preferably the same one in which you have put the procedure prototype. Then, use the LIKEDS keyword in your program to make a copy of the template data structure for your program to use. This way, the programmer calling the procedure will not have to define the data structure manually. See the sidebar "How to use the LIKEDS keyword" (below) for more information on using the LIKEDS keyword.

It's never too late to modularize

If you see an opportunity to modularize in an existing app, seize it. It is never too late to strip some code out of an existing program and make a separate procedure with it, especially if the code is reusable. Doing so can improve productivity drastically.

Let's look to the April 2007 issue of Inside Version 5 for a perfect example of this. In "Embedded SQL programming without SQL/400 – A working example" (see sqlcli.txt and #sqlcli.txt), we showed you a fairly long program that uses the SQL CLI APIs to achieve embedded SQL. Most of the code is for SQL environment setup and cleanup and is the exact same process any program would have to go through before actually running an SQL statement. This, then, presents a perfect opportunity to modularize after the fact.

First we strip out the setup code and create a procedure called SQLSetup. Then we strip out the cleanup code and put it in a procedure called SQLCleanup. These two procedures, along with the ChkSQLRC procedure, are put into a separate module called SQLCLIXTRA (see sqlclix.txt). To support this module, we either need to add to the previous include file (i.e., #sqlcli.txt) or create a separate one (see #sqlclix.txt).

The same working example program shown last month is now considerably shorter and much easier to read (see sqlcli2.txt). Plus, if coded from scratch, it would have taken much less time.

Keep posted for the rest of the tips next time.

Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
iSeries administrator tips
Analyze the health of your IBM i server with iScore
Researching high availability for your System i shop
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Database performance comparisons on IBM i
Translating Linux for IBM i admins: User profile commands
Modern System i reports using Client Access
Tips for installing Lotus Domino server on a System i partition

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts