Question Procedure or Class?


Obviously classes and methods are more modern than procedures and functions. Even if you don't use inheritance and class hierarchies and simply use singleton classes as libraries methods allow you to let the compiler check the parameters (works for functions, but not for procedures) but still throw errors at run-time (functions can't return errors).
There are some performance issues with calling methods and object instantiation, though. Hopefully Progress will continue to work on this.

Cringer Moderator
Staff member
This is the wrong question. You can write a Class and use exactly the same design strategy as you would with a Procedure. The question you should be asking is whether you use Procedural or Object Oriented design. Object Oriented is designed for creating reusable code, but there are costs, one of which andre has already mentioned.
I'm very new to the OOABL world myself, but I wouldn't go back. There are things we do in our application which it would be very hard to reproduce procedurally.

Rob Fitzpatrick Sponsor
which is better and why?
I've seen misuse of "old" coding techniques (e.g. "nested-include hell", turning .p files into internal procedures, etc.; list is nearly endless) and "new" ones (e.g. multiple layers of abstraction for no good reason).

In general terms, I think the person wielding the tool is at least as important as the tool itself; specifically, their experience, skill, discipline, attention to detail, knowledge of good patterns and practices, and concern for writing good maintainable code.

Other people here can give you more specific reasons to choose OO techniques and you've already heard some. But I can say from experience that people who are new to OO and who don't have a solid grounding in the concepts will write bad code that will likely have to be rewritten. Shiny and new, but bad. That certainly isn't an argument against OO patterns; just an observation.

There are things we do in our application which it would be very hard to reproduce procedurally.
I agree. I am starting to dip my toes in this OO world. After examining and playing with a UserTableStatistics class from Mike Fechner and Tom Bascom on Github, I've started writing code of my own that follows a similar pattern. It's actually quite elegant (the pattern, not my code ;)). It makes collection of data from multiple databases much easier and more flexible than the procedural equivalent.
I'm asking this question because I can make simple reusable codes on both procedure and class (of course same logic but different coding design) . Thanks for your insight guys. Now I know that class is still better than procedure in terms of creating dynamic and maintainable codes.


Well-Known Member
In my experience ...

It does not matter much whether you go OO or stay procedural when the goal is to produce reusable code. Documentation and easy to use APIs are most important. Because, if documentation is missing or the APIs are hard to use nobody will re-use them. Therefore you should put your emphasis on a good API management which enforces up-to-date documentation, easy discovery and use.

Still - I find it easier to implement such things in OO ...