For discussion following see following forum link containing source code:
Source code: Don't be intimidated by this source code!
The techniques used in the code above are uncommon to most COBOL programmers.
It is object-based (or more correctly class-based) programming.
Some issues
-> I have seen many discussions on the goto statement.
<- The design of class-based programming completely eliminates the need for goto!
-> I have seen many discussions of deeply nested IF or PERFORM statements.
<- The design of class-based programming completely eliminates the need for deeply nested 'anything'!
-> I have seen discussions on the need for paragraph prefixes (such as: 1000-init, 2000-main, 3000-final, 6000-sub-program, ...)
<- The design of class-based programming is not lineair. Therefore prefixes have no meaning (that is: it is not true that first 1000-init is executed, then 2000-main and then 3000-final ... it all depends on the method being executed).
-> Non class-based programs tend to contain large EVALUATE statements that grow over time.
<- The design of class-based programming eliminates the need for large EVALUATE statements and is much more adaptable to change.
The challenge is this:
1. Try to create a traditional version of the code above (a set of simple table sort routines) with less complexity.
(I can sent an original (traditional) source to those not having the time or will to code. Just sent a mail request to: Mailto: ahlers_wim@hotmail.com )
2. Once you have done that (and only after you have done that)!
Add the option for new sort criteria. Assume following feature is requested by customer, request:
"sort packed-decimal fields on absolute values. Therefore: abs(2) is equal to abs(-2)".
...prediction for traditional procedural code:
1. The number of 'IF' or 'EVALUATE' statements will grow.
2. The existing sorts will be unstable during the implementation process.
3. Internal reuse will degrade.
4. Over time, the program will become more and more complex.
5. The procedural code will have less coding lines then a class-based code but will be more complex.
...prediction for the class-based code:
1. An 'ENTRY' is added for each new feature. But there are no additional selection criteria.
2. Existing sort functionality is completely unaffected.
3. Internal reuse will increase.
4. The 'to-be-added' functionality is completely isolated and therefore does not increase at all the existing complexity.
5. The class-based code will have more coding lines then procedural code but will be less complex.
...of course, with great discipline you can achieve the above with traditional procedural coding as well.
But class-based or object-oriented techniques, when properly used, makes it so much easier.
Regards, Wim.
Source code: Don't be intimidated by this source code!
The techniques used in the code above are uncommon to most COBOL programmers.
It is object-based (or more correctly class-based) programming.
Some issues
-> I have seen many discussions on the goto statement.
<- The design of class-based programming completely eliminates the need for goto!
-> I have seen many discussions of deeply nested IF or PERFORM statements.
<- The design of class-based programming completely eliminates the need for deeply nested 'anything'!
-> I have seen discussions on the need for paragraph prefixes (such as: 1000-init, 2000-main, 3000-final, 6000-sub-program, ...)
<- The design of class-based programming is not lineair. Therefore prefixes have no meaning (that is: it is not true that first 1000-init is executed, then 2000-main and then 3000-final ... it all depends on the method being executed).
-> Non class-based programs tend to contain large EVALUATE statements that grow over time.
<- The design of class-based programming eliminates the need for large EVALUATE statements and is much more adaptable to change.
The challenge is this:
1. Try to create a traditional version of the code above (a set of simple table sort routines) with less complexity.
(I can sent an original (traditional) source to those not having the time or will to code. Just sent a mail request to: Mailto: ahlers_wim@hotmail.com )
2. Once you have done that (and only after you have done that)!
Add the option for new sort criteria. Assume following feature is requested by customer, request:
"sort packed-decimal fields on absolute values. Therefore: abs(2) is equal to abs(-2)".
...prediction for traditional procedural code:
1. The number of 'IF' or 'EVALUATE' statements will grow.
2. The existing sorts will be unstable during the implementation process.
3. Internal reuse will degrade.
4. Over time, the program will become more and more complex.
5. The procedural code will have less coding lines then a class-based code but will be more complex.
...prediction for the class-based code:
1. An 'ENTRY' is added for each new feature. But there are no additional selection criteria.
2. Existing sort functionality is completely unaffected.
3. Internal reuse will increase.
4. The 'to-be-added' functionality is completely isolated and therefore does not increase at all the existing complexity.
5. The class-based code will have more coding lines then procedural code but will be less complex.
...of course, with great discipline you can achieve the above with traditional procedural coding as well.
But class-based or object-oriented techniques, when properly used, makes it so much easier.
Regards, Wim.