All Questions
7 questions
1
vote
2
answers
196
views
Should I add functionality by adding a new method to a class - or should I "register" the new functionality into a data structure?
I have one large class that computes ~50 different metrics (each metric has no side effects).
My code is similar to this:
class ReportingMetrics:
def __init__(self, data:pd.DataFrame, config:dict)...
0
votes
1
answer
367
views
What's the benefit of separating specialised data from behaviour in an algorithm?
Functional programming strongly suggests to separate data from behaviours (functions). However, I can't see the benefit of this for an algorithm's implementation intrinsically tied with particular ...
14
votes
3
answers
3k
views
Sum Types vs Polymorphism
This past year I took the leap and learned a functional programming language (F#) and one of the more interesting things that I've found is how it affects the way I design OO software. The two things ...
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 ...
0
votes
2
answers
751
views
Is this instance of mixing FP and OOP a good design?
I had a strange-feeling pattern come up in some code I was writing. In a project with user accounts, there was a lot of code that needed to do common things such as creating accounts, deleting them, ...
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 ...
7
votes
1
answer
4k
views
C++ Design: Functional Programming vs OOP
Design Question
Recently, I've been doing more and more FP in C++, mostly in the form of function templates and lambdas, and heavy overloading of a single function name. I really like FP for some ...