Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of the mediator pattern in functional languages?

In C# I am used to Mediator and its related pattern, however I am slowly moving to F# and I am wondering if there is something equivalent functional languages.

like image 270
Natalie Perret Avatar asked Sep 20 '25 06:09

Natalie Perret


1 Answers

Since the Mediator pattern is an Object Oriented (OO) design pattern and F# is a functional language, OO patterns won't always directly translate to functional programming because there is not necessarily a 1-1 equivalent mapping from all OO design patterns to functional design patterns. Functional programming languages have their own types patterns for various problem solutions that are different than the standard OO patterns. F# has built in language support for functional programming techniques that are much more difficult or simply not available in C#, and many times these features can make implementing equivalent behavior much easier in F#.

For some good examples: Scott Wlaschin has several recorded talks on Functional Design patterns if you're interested in learning more about them.

https://fsharpforfunandprofit.com/fppatterns/

Most problems solved by OO patterns in an OO language are solved in a functional language using functional programming techniques rather than specific design patterns.

like image 108
Fred Ferenczhalmy Avatar answered Sep 22 '25 22:09

Fred Ferenczhalmy