▲ | GiorgioG 3 months ago | ||||||||||||||||
As a 20+ year C# dev...where do I learn how to structure apps in F#? In C# my ASP.NET Controller might use a service (or a mediator) to execute some domain logic and that in turn will use a repository pattern (or EF DbContext) to update/query a database. How are dependencies injected in? It seems like there are multiple ways of going about it, but I don't have enough knowledge of F# to know 'the proper way' to do it. | |||||||||||||||||
▲ | JohnyTex 3 months ago | parent | next [-] | ||||||||||||||||
The situation is a bit more complex in F# than C#, as there are multiple ways to do it. Scott Wlaschin has a good overview post about it here: https://fsharpforfunandprofit.com/posts/dependencies/ FWIW you can do it exactly the same way you do it in C#; it’s not “wrong”, it might just feel a bit out of place. | |||||||||||||||||
▲ | Lanayx 3 months ago | parent | prev | next [-] | ||||||||||||||||
I wrote an article about it. https://medium.com/@lanayx/dependency-injection-in-f-the-mis... | |||||||||||||||||
▲ | aaronmu 3 months ago | parent | prev [-] | ||||||||||||||||
Just start. Use whatever style you are used to. Use controllers. Adapt your style as F# pulls you deeper inside the pit of success. You'll struggle the first couple of features, but you'll reach a sweet spot between your current style and functions relatively fast. | |||||||||||||||||
|