Replies: 1 comment 8 replies
-
Thanks @trmalek!
1.a) The plain vanilla Java approach would be private variables firstName, and lastName, and then hand-writing get firstMame, setFirstName methods. One could consider this the "purest" approach, since no dependency on any library, i.e. plain Java. Regarding these three approaches, there isn't yet a globally accepted consensus which way one should go, so I see them all as valid, though this is a great topic, because a team should think about which way to go. Regarding the lombok experimental, yes, the reason is due to the @UtilityClass - it's for classes which only static methods, so I avoid writing a private constructor. Again could have been done with plain Java. In other languages (like C#), this isn't necessary since C# already has a static keyword for classes...
3.a In Uncle Bob's original Clean Architecture page https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html he writes about the Presenter, and the flow with Use Case Input Port, Use Case Interactor, Use Case Output port. This kind of approach is illustrated by @ivanpaulovich here https://github.com/ivanpaulovich/clean-architecture-manga/tree/main/accounts-api/src/Application/UseCases/Deposit 3.b. Another approach is without the presenter, but instead use case handlers WITHOUT presenters, which Uncle Bob takes here (this was done several years after his blog post above) https://github.com/sandromancuso/cleancoders_openchat/blob/openchat-unclebob/src/main/java/org/openchat/usecases/GetSubscribedDocuments.java and that approach is also visible in Ian Cooper's clean architecture example, i.e. request/response and use case handler. Both of these approaches are without presenters. I thought about this during the past few years, I currently prefer 3.b. Furthermore, in 3.b. one may pass in separate args into the use case, e.g. no Request object, but rather separate args, or having a Request object which holds multiple variables. I prefer it withRequest objects. Overall, this is a good topic, I want to document these different approaches and pros and cons. |
Beta Was this translation helpful? Give feedback.
-
Hello,
first of all thank you on the effort and all your linkedin posts. That's very interesting.
Allow me to send you a few remarks on the banking kata code (for information, I am not from the java world, so some remarks may not be valid):
Best regards.
Beta Was this translation helpful? Give feedback.
All reactions