Closed sdeleuze closed 2 years ago
Hey there @sdeleuze, I would really be happy to take charge of this issue, if you think that it is possible. I love the DSL, but the main issue that I see for a large adoption is exactly the lack of documentation (compared to regular Spring). Then it would be an honour for me to contribute to it. What do you think about it?
Hi, your help on this would be appreciated since indeed we really lack of documentation. Happy to provide support if needed. I would suggest to use JDBC instead of JPA as done in https://github.com/spring-projects-experimental/spring-fu/tree/main/samples/kofu-petclinic-jdbc for the Kofu version. Could you write it in Asciidoc?
We could add Jafu version in a second time.
Yes, I think that writing in Asciidoc is not a problem. But where should I provide the documentation? Maybe a PR on this project with a new folder tutorial
containing the new doc?
JDBC is ok for me... but why not Exposed? It is more Kotlin oriented. Anyway, also JDBC is fine.
Would you suggest starting with the Spring initializer even if there is no template for the functional main
? Or maybe I could just go enumerating the maven dependencies?
Also... springboot or springwebflux?
Maybe a PR on this project with a new folder tutorial containing the new doc?
A PR on this project is fine yeah.
JDBC is ok for me... but why not Exposed? It is more Kotlin oriented. Anyway, also JDBC is fine.
The goal is to be able to provide both KoFu and JaFu samples so sticking to JDBC seems a better choice for that purpose.
Would you suggest starting with the Spring initializer even if there is no template for the functional main? Or maybe I could just go enumerating the maven dependencies?
Yes starting from start.spring.io and replacing the main function is probably the best way.
Also... springboot or springwebflux?
I assume you mean Spring MVC or Spring WebFlux. Let's use Spring MVC to target a wider audience and be consistent with JDBC blocking persistence.
Ok perfect. I was thinking about proposing to substitute mustache with Kotlin HTML DSL, which is more idiomatic. But if the goal is to provide also JaFu examples... then I suppose that mustache is a better choice as well 😄
Hi @sdeleuze, it took a while but I finally started on this task! I suppose no one did it yet, as the issue is still open. Before writing the tutorial, I started implementing the example code. Would you mind giving me some feedback? Here is the repository https://github.com/lucapiccinelli/spring-kofu-tutorial-draft.
I implemented:
I'm not a fan of JPA, but it is objective that when choosing not to use it, you lose some interesting features, like lazy fetching. Then I thought of giving a suggestion of how to implement it using lazy Kotlin delegate. Please have a look at this and this.
Also, I used sealed classes to model if a (domain) Entity needs to be inserted or updated. Have a look here and here
Please tell me if this is ok for you or it is too much for a tutorial. If you mind about Java examples, sealed classes semantics can be reproduced using a Visitor pattern. The lazy operator could just be avoided in Java examples.
If my approach is ok for you, I will continue with the rest of the examples. I can also have a step back and void using sealed classes and lazy delegate. Thank you!
Hello @sdeleuze, I started writing the tutorial here https://github.com/lucapiccinelli/spring-fu/tree/kofu-tutorial/samples/kofu-tutorial. As an introduction, I copy/pasted your README of KoFu. I think it is good to introduce what we are talking about.
When you have time, please tell me your thought about it. Especially about Content of this tutorial.
Have a nice day!
Hey, thanks for working on that, looks great. I will discuss with @poutsma what should be the next steps and let you know.
The tutorial is done. I will proceed with a pull request, so that you can review it. I did the homework...but please verify that what I wrote is correct.
Spring Fu version of https://spring.io/guides/tutorials/spring-boot-kotlin/