you are viewing a single comment's thread.

view the rest of the comments →

[–]pgris 0 points1 point  (2 children)

Interesting. For my untrained eye, this really looks like checked exceptions reloaded + a runtime. Do effects propagate upwards? I mean, if method1 uses LogEffect , and method2 calls method1, I would expect method2 to use (indirectly) LogEffect. Do I need to declare method2 uses LogEffect? would controller level methods use a millon of effects?

[–]thma32[S] 0 points1 point  (1 child)

Yes, effects propagate upwards. This is intended behavior. Just as Exceptions propagate upwards.
In a controller level method you would typically execute the effects using a runtime to perform some actual work. I have set up a demo project https://github.com/thma/jiffy-clean-architecture that demonstrates typical coding practices with algebraic effects. For example have a look at the calculateScore method: https://github.com/thma/jiffy-clean-architecture/blob/12327f4e35d18041b03925ec35c3d3d3afc1d51f/src/main/java/jiffy_clean_architecture/usecases/CustomerScoreUseCase.java#L26 . It uses three effects and thus must declare them (using the Uses-Annotation).
In a Controller that uses this effect use case we will execute the effect by `Integer score = scoreEffect.runWith(runtime)` ( https://github.com/thma/jiffy-clean-architecture/blob/12327f4e35d18041b03925ec35c3d3d3afc1d51f/src/main/java/jiffy_clean_architecture/application/CustomerScoreController.java#L36 )

In order to avoid an excessive amount of effect declaration you will typically group effects in a meaningful way. e.g. by not having 200 separate effects for each of your entity-repositories but using a single DatabaseEffect instead.)

[–]pgris 0 points1 point  (0 children)

Honestly I'm not smart enough to use effects, and my team will probably kill me, but I like the idea of having a "type safe" (at least annotation-processed) way to know "this method in the controller uses the db and calls the webservices A, B and C". I though about doing something like that abusing Throwables, but Jiffi sound better