3 ms·
The only problem I found with this approach is to manage state and dependencies: say, if the functions need to work with database, it is not convinient to send
by playing_colours 8y ago
The only problem I found with this approach is to manage state and dependencies: say, if the functions need to work with database, it is not convinient to send it as a parameter. A class instance initialised with a database looks more feasible in my opinion.
- dfee 8y agoYour alternative is dependency injection. What you seem to be describing is class factories (I.e. the use of meta classes) which /is/ OOP. That said, I think OOP is fine. And so is FP. They’re just tools, and I would prefer to model nouns in the former, and model verbs with the latter.
- aidos 8y agoThat’s a pattern I use a lot. Passing services and connections around everywhere is a pain, but I like to stick to a more functional style. I generally use classes as a place to hold context (E.g. dB connection) and then use a functional style within the class. Works as a fairly happy medium for me.