IBM i > DEVELOPER > RPG

What Every RPGer Needs to Know, Part 1

The first five of our top 10 list of important skills


 

Our articles cover many topics we think RPGers need to know. While there are many useful skills RPGers should have, we recently decided to develop our current “Top 10” list of important skills and share them with you. We only have room for five in this article, so we’ll finish the list next month. Your top 10 may be different, and ours will certainly change over time, but, for what it’s worth, here’s what we currently think every RPGer should know and why.

1. How to Use RPG IV for Real

What do we mean by “for real?” We mean truly taking advantage of the modern language that is today’s RPG and replacing old coding styles and techniques with code that’s easier to read and maintain. Many RPGers don’t think readability is important. Some even seem proud that their code is hard to read—as if it should be because, after all, it was hard to write. We believe readable code not only improves productivity, it produces more reliable code. If the code is easier to understand, fewer errors will be made when maintaining it.

What kinds of things make our code more readable? Some may disagree, but we feel that /Free format logic is far more readable than fixed format logic—assuming, of course, that the /Free logic is written properly, with indentation to help illustrate nested logic blocks.

/Free logic also forces programmers to use more modern coding styles since it doesn’t support many older RPG features. Programmers must learn to replace old-style operation codes with their modern equivalents or built-ins. To a great extent, numbered indicators bite the dust, replaced with far more meaningful functions and/or named indicators.

Besides /Free logic, longer field names, mixed case and completely blank lines (without even an * or // at the beginning) to break up logic blocks also go a long way toward more readable code.

If you could use some help brushing up your skills in this area, see some of our earlier writings on the subject: “Goodbye, Indicators!”, “Susan’s Favorite New RPG Feature” and “Breaking Old RPG Habits.”

2. Prototypes for All Calls

One of our first EXTRA articles ever was about prototyping program calls. That was a long time ago, but we still find that far too few RPGers use prototypes regularly.

Prototypes can make for more reliable code by allowing the compiler to catch errors that we might not catch ourselves during testing. They can also reduce our program logic because the compiler can take on some of the menial tasks of moving data around into the right type and size of fields to pass as parameters.

Of course, using prototypes to do your calls is only as good as the prototypes themselves. That’s why it’s highly recommended that prototypes be placed in a special source member that lets them be /Copy’d into the calling program’s source. That way, once a prototype has been written, tested and proven accurate, all other callers to that code should use that same proven prototype.

To learn more about how and why to use prototypes, read “RPG IV Prototypes: What are they and why should you care?”, “The Case of the Missing Parameters” and “Adding ‘Value’ to Your Prototypes.”

 

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.



Advertisement

Advertisement

2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters