Is it better to program COBOL using modules, or have everything you need in one code?

So I have recently entered what I would consider an “intermediate” level in the language, and I am making my own codes. At the moment I am planning out a program for record I/O (Adding to a record, amending record fields, deleting records etc etc). So now I would like to know if it is acceptable practice to make modules for each individual utility and use CALL to run them all together (so for instance I have a separate module for record creation and another for deletion and CALL them in a skeleton program).

Using modules feels MUCH more intuitive to me personally and as far as I can tell it has some pros compared to doing it all in one code:

  • The modules can be used as templates for future programs and edited as needed.

  • The code is somewhat easier to edit, follow and amend, as every section exists in isolation. (This is debatable, but personally I find it to be that way)

  • Once you have made the module, its easier to understand how that segment works and if necessary you can adapt all modules into one big code

However it also arguably has some considerable drawbacks, for instance:

  • In some ways the code ends up being longer and less concise as with intelligent use of the PERFORM function many of the paragraphs end up being shared by multiple different sections of the code and therefore only need to be written once. But with modules they end up being written multiple times.

  • Using modules deprives you of the opportunity to use that PERFORM function intelligently, which is in my opinion one of the key skills for a COBOL programmer.

  • Using modules can also create challenges in the sense that now you also need to manage your COBOL files and keep track of them, on top of your data files. This makes it much harder to stay organized in the long run.

Sorry if any of my terminology is wrong, I am fresh into COBOL and I am still picking up the jargon. But anyway I would greatly appreciate any pointers on this dilemma, as I have heard conflicting responses to similar questions.

I have more than 20 years of COBOL experience.I would not use separate routines, as disadvantages outway advantages.

I’ve seen both kinds, and agree that for me the “all in one” approach is best. What I’ve done is clone these to do different jobs when there are different needs.

The modules would be OK if it were a simple need but there can be a lot of work keeping them generic enough to handle “any” kind of record, file, etc.

So, it’s your call, but I vote “all in one”.

1 Like