user3528438
user3528438

Reputation: 2817

Functional style OOP?

What if I make member variables as const as possible and treat frequently changing data as input argument to the interface method.

So instead of data owning methods that operates on itself, methods owns parameters(const members) and operates on data.

Is this kind of style functional or functional-style, or just call it "stateless OOP"?

Is there any reason to encourage or discourage it?

Upvotes: 1

Views: 68

Answers (1)

zcleghern
zcleghern

Reputation: 827

I wouldn't call it functional, as functional tends to imply that your program is made of composable functions (pure functions ideally). However, the "tenets" of functional programming seem to be there- immutability, referential transparency. The only thing you are (potentially) lacking is functions as first class objects. To truly be considered functional programming you really need to have functions that are treated as first class objects- they can be assigned, passed as arguments, and returned from other functions. So I think this would be considered OOP with functional elements.

Someone who is more well-versed in programming language design feel free to modify or refute this answer!

Upvotes: 1

Related Questions