Skip to main content

All 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)...
MYK's user avatar
  • 343
3 votes
1 answer
188 views

Choosing the design of a scientific DSL: purely or impurely functional?

My aim is to create a language specific to the scientific field (which would be used mainly in the field of machine learning and physics) which would be based on the functional paradigm, a paradigm ...
Foxy's user avatar
  • 621
5 votes
3 answers
3k views

Significant difference between functional and procedural collection handling [closed]

I'm planning an empirical study on function passing - specifically lambdas aka anonymous functions aka arrow functions. Now, although functional or even object-oriented approaches are highly favored ...
Nils Mehlhorn's user avatar
0 votes
1 answer
113 views

Is duplicating, deleting, pushing, and/or an object to/between lists a code smell?

I'm thinking about a structure like this. cardGame: players: - john: hand: - card: id: 1 suit: diamond ...
Nina Reynolds's user avatar
8 votes
3 answers
3k views

Is it preferable to "compose" monadic functions or "chain" them?

To the best of my understanding Monads were created to allow for composing functions with those that had potential side-effects - loosely speaking. For me composition implies code like so: f(g(h(x)))...
PhD's user avatar
  • 2,541
2 votes
1 answer
286 views

Functional Approaches to Serializing Objects to Variable-length Byte Array Output

I have a large number of record types derived from a binary format specification. So far, I've already written a computation expression builder that let’s me read structures from the files easily: ...
Kevin Li's user avatar
  • 145
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 ...
schrödingcöder's user avatar
1 vote
2 answers
140 views

How can an iterative algorithm be controlled dynamically?

Suppose we need an iterative algorithm for mathematical optimisation. Each iteration takes a long and random time. After each iteration, a stopping condition is checked for the iterate x, based on ...
schrödingcöder's user avatar
0 votes
1 answer
177 views

Is the usage of flip function a smell for bad design?

Everything is in the title, is the usage of flip function a smell for bad design ? I'm coming from a JavaScript universe and used to work with lodash/fp or ramda. Recently, I've written some stuff ...
mfrachet's user avatar
  • 1,561
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 ...
Patrick D's user avatar
  • 271
3 votes
1 answer
410 views

Dependencies between functions-only modules: hardcoding vs alternatives

In switching from a procedural background to "FP in the small, OO in the large" I'm grappling with the following problem. Suppose there're modules, each only containing numerical math functions ...
schrödingcöder's user avatar
3 votes
2 answers
283 views

Should I provide partialed functions based on API call in Clojure?

I am designing a library to wrap an API with Clojure. The API requires user credentials to authenticate user related calls. My first approach was to have functions that do each task the API can do: (...
Moon Cheesez's user avatar
1 vote
1 answer
117 views

Simplified API one case class vs robust and multi ADT case class? [duplicate]

Below are oversimplified examples, but I wonder which route to take what is the best practice when designing API, the simple or the more complex and robust which is better? This looks good and goes ...
Jas's user avatar
  • 507
0 votes
3 answers
236 views

Use case, design, and how to append to an immutable object in functional programming

This is not (supposed to be) an opinion question, but it is a newbie question, so if there is just a resource I haven't found that I need to read, point me there :) I am in the design stages of a ...
Apollo's user avatar
  • 111
2 votes
1 answer
114 views

F# - Associating a function with the matching type of object

Let's say I'm programming a chess game. At some point I have to check, which moves are valid for a given piece. What would be the proper way to select the correct pathfinding function for a given ...
user avatar

15 30 50 per page