All Questions
Tagged with functional-programming object-oriented
95 questions
99
votes
5
answers
32k
views
Functional Programming vs. OOP [closed]
I've heard a lot of talk about using functional languages such as Haskell as of late. What are some of the big differences, pros and cons of functional programming vs. object-oriented programming?
79
votes
10
answers
17k
views
How functional programming achieves "No runtime exceptions"
How does a functional programming language, such as Elm, achieve "No runtime exceptions"?
Coming from an OOP background, runtime exceptions have been part of whatever framework that is based ...
54
votes
3
answers
7k
views
Why is an anemic domain model considered bad in C#/OOP, but very important in F#/FP?
In a blog post on F# for fun and profit, it says:
In a functional design, it is very important to separate behavior from
data. The data types are simple and "dumb". And then separately, you
have ...
53
votes
2
answers
9k
views
What did Alan Kay mean by "assignment" in The Early History of Smalltalk?
I have been reading The Early History of Smalltalk and there are a few mentions of "assignment" which make me question my understanding of its meaning:
Though OOP came from many motivations, two ...
50
votes
9
answers
14k
views
Return considered harmful? Can code be functional without it?
OK, so the title is a little clickbaity but seriously I've been on a tell, don't ask (TDA) kick for a while. I like how it encourages methods to be used as messages in true object-oriented fashion. ...
38
votes
7
answers
9k
views
Do you need to think about encapsulation if you can ensure immutability?
Encapsulation
In object-oriented programming (OOP), encapsulation refers to the
bundling of data with the methods that operate on that data, or the
restricting of direct access to some of an ...
36
votes
7
answers
12k
views
Functional programming compared to OOP with classes
I have been interested in some of the concepts of functional programming lately. I have used OOP for some time now. I can see how I would build a fairly complex app in OOP. Each object would know how ...
31
votes
6
answers
7k
views
Does learning a functional language make a better OOP programmer? [closed]
As a Java/C#/C++ programmer I hear a lot of talk about functional languages, but have never found a need to learn one. I've also heard that the higher level of thinking introduced in functional ...
30
votes
18
answers
6k
views
What would you do if your client required you not to use object-oriented programming?
I am writing a program to simulate the activity of ants in a grid (PDF). The ant can move around, pick up things and drop things.
The problem is while the action of the ants and the positions of each ...
30
votes
10
answers
3k
views
Given a herd of horses, how do I find the average horn length of all unicorns?
The question above is an abstract example of a common problem I encounter in legacy code, or more accurately, problems resulting from previous attempts at solving this problem.
I can think of at ...
30
votes
5
answers
11k
views
How to refactor an OO program into a functional one?
I'm having difficulty finding resources on how to write programs in a functional style. The most advanced topic I could find discussed online was using structural typing to cut down on class ...
30
votes
10
answers
5k
views
How would Functional Programming proponents answer this statement in Code Complete?
On page 839 of the second edition, Steve McConnell is discussing all the ways that programmers can "conquer complexity" in big programs. His tips culminate with this statement:
"Object-oriented ...
29
votes
4
answers
7k
views
Is pattern-matching against types idiomatic or poor design?
It seems like F# code often pattern matches against types. Certainly
match opt with
| Some val -> Something(val)
| None -> Different()
seems common.
But from an OOP perspective, that looks ...
27
votes
6
answers
7k
views
Is functional programming a superset of object oriented?
The more functional programming I do, the more I feel like it adds an extra layer of abstraction that seems like how an onion's layer is- all encompassing of the previous layers.
I don't know if this ...
27
votes
7
answers
4k
views
Does functional programming ignore the benefits gained from the "On the Criteria To Be Used in Decomposing Systems into Modules" (data hiding)?
There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles ...