Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Procedural vs OOP modules

by hippo (Bishop)
on Oct 29, 2021 at 09:32 UTC ( #11138193=note: print w/replies, xml ) Need Help??


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.


🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2022-05-25 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?