Functional Programming Design Patterns

So for those who are going through the documentation you have probably noticed that Motoko is based off of a more functional design. This language design can be a little more difficult for people switching from an Object Oriented programming language.

For those trying to make the transition I suggest you watch this youtube video: https://www.youtube.com/watch?v=srQt1NAHYC0. I think the guy in the presentation breaks down what functional programming is all about along with some solid design patterns for you to move forward with.

Please feel free to leave some design patterns you are favoring for Motoko on this thread as well so we can start building a good library of solid principles.

10 Likes

thanks for sharing! i’ll try to watch this over the weekend

2 Likes

If you’re not familiar with folding in functional programming, this article is a good primer:
https://medium.com/@zaid.naom/exploring-folds-a-powerful-pattern-of-functional-programming-3036974205c8

(Those who know group theory will find it relates).

Motoko’s Array and List fold functions can be found here:
https://sdk.dfinity.org/language-guide/index.html#stdlib-array

2 Likes