Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Abstracting over Data vs Abstracting over Behavior

I am reading a book about Lambdas expression in Java and I came across this sentence

The difference is that object-oriented programming is mostly about abstracting over
data, while functional programming is mostly about abstracting over behavior.

Can anyone be kind and elucidate the difference that is mentioned in above sentence?

Source : http://shop.oreilly.com/product/0636920030713.do

like image 691
Kick Buttowski Avatar asked Oct 21 '25 13:10

Kick Buttowski


2 Answers

The irony is that people can come up with infinite analogies when trying to compare FP to other paradigms.

In this particular case once you figure out what does "abstracting over something" means, you could solve the riddle.

Abstracting over something would mean you hide the details of that something and provide abstractions to access that something so that to the outside world the details of that something are not visible.

Applying the above theory we would get that:

In OOP you would hide the details of data and provide abstractions (interfaces, classes etc) to access the data.

In FP you would hide the details of behavior and provide abstractions (modules i.e a set of functions) to access the behavior.

like image 174
Ankur Avatar answered Oct 23 '25 05:10

Ankur


I would have written it like "The difference is that object-oriented programming is mostly about relation and communication between real time objects,while functional programming is mostly oriented to the desired result."

When you are working in OOP languages, the given domain is usually very importent to you. On the other hand, with functional languages you do not care about the domain but only about the deterministic result which should be achieved.

like image 45
Mirek Surma Avatar answered Oct 23 '25 04:10

Mirek Surma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!