Project Structure, Design Patterns for ClojureScript (backend/frontend)

Hello,

I got a lot of helpful responses from this forum before so here is another question :slight_smile:

We know that in the OOP world there is MVC and it’s derivatives, but what does exists for Functional Programming and ClojureScript more specifically?

I know some people don’t like the design pattern sentence, but is there at least an article that suggests a good project organization?

Up to now, I’m experimenting with reagent and reframe which kind of drive my project organization based on my experience with React and JavaScript.

Consider functional core, imperative shell:

https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell

You might also be interested in @ericnormand’s work.

I’ve head of FRP before https://en.m.wikipedia.org/wiki/Functional_reactive_programming and I guess there’s whatever Elm does since 0.17 https://elm-lang.org/news/farewell-to-frp

Thanks for the suggestions guys.

I’m replying to myself in case any other newcomer has the same question as me .

As a JavaScript developer what “clicked it” for me was reframe, particularly after reading this: https://purelyfunctional.tv/article/react-vs-re-frame/

After reading this, and going through the examples and articles that are in Re-frame’s repository I believe I have a much better understanding on how to architect a front end project in ClojureScript.

I consider OOP a design patter by itself, of course is something bigger than MVC, but I say it because you can use it independently of the language. Clojure has structures to maintain state like an object, so if you think some aspects of OOP and MVC works for you I say you could go for it.

I work more with frontend and I also use re-frame and I recommend, with its basics you can do 90% of the data flow managing stuff. But I don’t like to have a single namespace for events and another to subs, I prefer to have them close where I use them with the views. I also recommend devcards, it’s a great way to see all your views at once and glance for errors.

You made me remember a talk by Uncle Bob where he talks about MVC, it might be more about architecture and not about design patterns, but I believe this kind of content is very useful and also language independent(ish). I also recommend his book Clean Architecture.

Stuart Sierra’s talk on Functional Design Patterns is good from Strange Loop 2013.

There is a funny (and informative) blog post that looks at the classic “Gang of Four” design patterns in Clojure.

Chapter 12 of “Clojure Programming” Emerick et al (O’Reilly) covers design patterns (again, mostly saying that “they’re just functions” similar to the blog post above).