http://qs1969.pair.com?node_id=11138193


in reply to Procedural vs OOP modules

At a high level the question is, "Should whatever this module represents be an object?" and the answer is often obvious from the context of its use. If the code to use the module will (or could) have more than one of the thing, then it should be an object and your module should represent a class.

At a low level the question is, "Does this code need to work with existing code which is already OO?". eg. if you are looking to extend/replace existing OO code then equally the answer should be yes.

You can always mix procedural and OO within one module if required/desired. And don't forget about functional either. Horses for courses.

Finally, if you still aren't sure which way to go, try writing your tests first (before the code which they will test). That may make the preferred paradigm clearer.


🦛