惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
D
Docker
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
量子位
有赞技术团队
有赞技术团队
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
B
Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
月光博客
月光博客

IT Jungle

Finally: Some Pricing Information On The Power S1112 Entry Server - IT Jungle Rocket Automates Manual IBM i Tasks With AI - IT Jungle Guru: Where’s The Table? - IT Jungle LaserVault Goes iSCSI With Virtual Tape Library - IT Jungle IBM i PTF Guide, Volume 28, Number 31 - IT Jungle Will Power Chips Get A Converged Arm Instruction Set Like Z Mainframe CPUs? - IT Jungle Thinking About Moving IBM i To The Cloud? Don't Start With The Quote - IT Jungle Precisely To Add Ransomware Protection In MIMIX 11 - IT Jungle It’s D-Day For Cybersecurity, AI Firms Warn - IT Jungle IBM i PTF Guide, Volume 28, Number 30 - IT Jungle Oracle Dips A Toe Into IBM’s EBCDIC World - IT Jungle When Your Small IBM i Team Is Really A Team Of One - IT Jungle Guru: Putting Failure Handling In Its Place - IT Jungle Inside The Security Enhancements In ACS - IT Jungle IBM i PTF Guide, Volume 28, Number 28: A Crazy Number of Security Vulnerability Patches - IT Jungle IBM i PTF Guide, Volume 28, Number 29 - IT Jungle IBM i PTF Guide, Volume 28, Number 28: A Crazy Number of Security Vulnerability Patches - IT Jungle Inside The Encryption Key Management Changes In IBM i 7.6 - IT Jungle FalconStor Moved To The Blue Lagoon, And Is Poised For Growth Because Of It - IT Jungle Guru: Claude’s SQL Tip - IT Jungle Astera Makes Extracting Legacy Report Data an AI Specialty - IT Jungle IBM i PTF Guide, Volume 28, Number 27 - IT Jungle Welcoming The New IBM i Chief Architect And Other New Top Brass - IT Jungle A Deep Dive Into That Power S1112 Entry Power11 Server - IT Jungle Guru: Beyond Three-Part Naming – Running SQL Across Remote IBM i Systems - IT Jungle How IBM Bolstered IBM i Resilience In The Summer Tech Refreshes - IT Jungle IBM i PTF Guide, Volume 28, Number 26 - IT Jungle Power Systems Has A Great Quarter; System Z, Not So Much - IT Jungle Does AI Mark The End Of The ERP Era? - IT Jungle Guru: Deterministic Application Development With AI - IT Jungle
Guru: Cohesion First – What A Procedure Should Be Respons...
Gregory Simmons · 2026-04-06 · via IT Jungle

April 6, 2026

One of the easiest mistakes to make in procedure-driven RPG is assuming that small procedures are automatically well-designed procedures. They are not. Size and cohesion are related, but they are not the same thing. A cohesive procedure has a single, clear responsibility. It exists to answer one business question or perform one business action. When a procedure tries to do more than that, it stops being a reusable building block and starts becoming a liability.

In procedural RPG, nothing enforces this discipline. There is no compiler warning when a procedure quietly takes on a second responsibility. There is no language feature that prevents a developer from adding just one more step because it happens to be convenient at the time. Over years of maintenance, those conveniences accumulate and cohesion erodes almost without notice.

If You Cannot Name It Clearly, It Is Doing Too Much

Naming is one of the most reliable cohesion tests available to an RPG developer. When a procedure name requires vague wording or starts to feel hand-wavy, that is often a sign that multiple responsibilities have been bundled together. Names like ProcessMushroomOrder or HandleMushroomInventory sound reasonable at first, but they conceal behavior rather than describe it.

Clear names force clear intent. A procedure named ValidateMushroomBatch sets an expectation. A procedure named CalculateMushroomYield tells the caller exactly what problem it solves. When naming becomes difficult, that is not a wording problem. It is a design problem.

Experienced RPG developers learn to treat naming friction as feedback rather than something to push through and ignore.

Business Actions Versus Technical Steps

Another common cohesion failure comes from mixing business logic with technical implementation details.

A procedure that determines whether a mushroom shipment meets quality standards should not also be opening files, managing commitment control, or writing audit records. Those tasks may occur as part of the same workflow, but they are not the same responsibility.

In practice, cohesive procedures tend to fall into two broad categories. Some express business intent and rules, such as determining whether a mushroom batch can be sold or calculating spoilage thresholds. Others handle technical concerns, such as reading inventory records or persisting inspection results. When those responsibilities are kept separate, procedural RPG code remains flexible and understandable. When they are mixed, every change becomes harder than it needs to be.

The Utility Procedure Trap

Utility procedures are often introduced with good intentions. A common date formatter. A reusable string cleanup routine. A helper that normalizes mushroom variety codes. Used carefully, these procedures can reduce duplication and improve consistency.

Problems arise when everything starts to look like a utility. Over time, many RPG systems accumulate service programs filled with loosely related procedures that exist simply because multiple programs needed them at some point. These service programs lack a unifying concept, and cohesion is lost at the module level even if individual procedures remain small.

Loosely purposed service programs also create fertile ground for cyclical dependencies. When a service program exists as a general collection of helpful procedures rather than a clearly defined capability, it inevitably begins to depend on other service programs that are just as loosely defined. Over time, those dependencies start to point in both directions. What begins as a convenient reuse decision, turn into service programs that present difficulties when compiling, tested, or reasoned about independently. Cyclical dependencies are not an accident. They are a structural signal that cohesion was lost earlier and never reclaimed.

A cohesive service program should represent a domain or capability, such as mushroom inventory management or quality inspection rules. When it becomes difficult to explain what a service program is responsible for in a single sentence, it has already grown beyond its useful boundaries.

Cohesion Is What Makes Reuse Safe

Low cohesion does not just make code harder to read. It makes reuse risky. When a procedure does more than its name or interface suggests, calling it in a new context becomes an act of faith. Developers begin to rely on side effects they do not fully understand, or they avoid reuse altogether and duplicate logic instead. Both outcomes slowly degrade the system.

Highly cohesive procedures behave predictably. A procedure that calculates mushroom shelf life should do exactly that and nothing more. That predictability is what allows procedure-driven RPG systems to scale over time without becoming fragile.

Cohesion Is a Daily Decision

Cohesion is not something that is designed once at the beginning of a project and then forgotten. It is a decision made every time a procedure is modified.

The moment a developer thinks, I will just add this here since I already have the mushroom data loaded, a design decision is being made. Sometimes that decision is justified. Often it is the first step toward a slow design failure that will not become obvious for years.

Procedure-driven RPG rewards developers who pause at that moment and ask a simple but uncomfortable question. Is this still the same responsibility? When the answer is no, the correct response is rarely the most convenient one. It is almost always the right one.

Until next time, happy coding.

Gregory Simmons is a Project Manager with PC Richard & Son. He started on the IBM i platform in 1994, graduated with a degree in Computer Information Systems in 1997 and has been working on the OS/400 and IBM i platform ever since. He has been a registered instructor with the IBM Academic Initiative since 2007, an IBM Champion and holds a COMMON Application Developer certification. When he’s not trying to figure out how to speed up legacy programs, he enjoys speaking at technical conferences, running, backpacking, hunting, and fishing.

RELATED STORIES

Guru: IBM i Job Log Detective Brings Structure To Job Log Analysis In VS Code

Guru: Managing The Lifecycle Of Your Service Programs – Updates Without Chaos

Guru: Are Binding Directories A Shortcut Or A Source Of Chaos?

Guru: Service Programs And Activation Groups – Design Decisions That Matter

Guru: Binder Source Is Your Service Program’s Owner’s Manual

Guru: Access Client Solutions 1.1.9.11 – Security First, With Continued Investment In SQL Tooling

Guru: Taming The CRTSRVPGM Command – Options That Can Save Your Sanity

Guru: CRTSRVPGM Parameters That Can Save or Sink You

Guru: A First Look at Bob, The IBM i Assistant That’s Closer Than You Think

Bob More Than Just A Code Assistant, IBM i Chief Architect Will Says

IBM Pulls The Curtain Back A Smidge On Project Bob

Big Blue Converges IBM i RPG And System Z COBOL Code Assistants Into “Project Bob”

Guru: When Attention Turns To You – Writing Your Own ATTN Program

Guru: WCA4i And Granite – Because You’ve Got Bigger Things To Build

Guru: When Procedure Driven RPG Really Works

Guru: Unlocking The Power Of %CONCAT And %CONCATARR In RPG

Guru: AI Pair Programming In RPG With Continue

Guru: AI Pair Programming In RPG With GitHub Copilot

Guru: RPG Receives Enumerator Operator

Guru: RPG Select Operation Gets Some Sweet Upgrades

Guru: Growing A More Productive Team With Procedure Driven RPG

Guru: With Procedure Driven RPG, Be Precise With Options(*Exact)

Guru: Testing URLs With HTTP_GET_VERBOSE

Guru: Fooling Around With SQL And RPG

Guru: Procedure Driven RPG And Adopting The Pillars Of Object-Oriented Programming

Guru: Getting Started With The Code 4 i Extension Within VS Code

Guru: Procedure Driven RPG Means Keeping Your Variables Local

Guru: Procedure Driven RPG With Linear-Main Programs

Guru: Speeding Up RPG By Reducing I/O Operations, Part 2

Guru: Speeding Up RPG By Reducing I/O Operations, Part 1

Guru: Watch Out For This Pitfall When Working With Integer Columns