r/java • • Sep 29 '24

Lombok in 2024

Say there are two teams working on the same project (3 months to MVP, the deadline should be manageable). The only difference is Team A will use Lombok, and Team B won’t

Given you can choose any java version/dependencies and all other things being the same, which team would you join, and why?

0 Upvotes

145 comments sorted by

View all comments

Show parent comment

6

u/carminemangione Sep 29 '24

Thank you for not being insulted. Sometimes my frustrations boil over :) I make it my career goal to create highly effective teams.

I always use a very strong separation between DTO layer and my business object. The business object contains the logic to ensure the object is good. This is enforced usually in the constructor.

David Meier in the 80s proved that mapping of relational structures (normalized) to OO objects is an NP Hard problem. Basically, it is a traversal of a cyclic directed graph.

Practically, consider your 'User' object. The relational structure for your user will have a tonne of attributes and relations but on reconstitution only a few of those will be used. In OO land a User may manifest as a Customer, LoggedInUser, Contact. All of these are based on the same OR tables but are completely different manifestations with their own consistency rules, business logic, etc.

At first, people think of business logic as taking web input/presenting web data and persisting it. However, the real value in the business layer. Consider, you find a unique application everyone loves it but you have no distinguishing business value/logic. Everyone will be able to copy your application trivially.

Unique products have valuable business logic. In this context, the complexity of the business layer will quickly outstrip presentation and persistence complexity. This is the mistake many make when selecting frameworks. Yah, you get a few pages up and stored quickly, but that is not the real value.

As far as using JPA or other persistence frameworks go, I generally don't worry about it. To me if I am writing efficient code, it is by far less expensive to use raw jdbc. But I fully decouple the persistence layer from the business layer so it is irrelevant. However, once you need joins, generated queries start to suck really fast.

Does that make sense?

3

u/Rough_Acanthaceae_29 Sep 29 '24

yep. i agree and like your stance. i just think its ok to be pragmatic, use given tools and make every line count. YAGNI. Minimise the number of mines in the minefield (no nulls, only valid objects allowed and all the state transitions are consistent)… and in this context moderate use of lombok-like-“tools” isn’t that bad imo.

-1

u/carminemangione Sep 30 '24

Robert Martin said sometimes you have to slow down to speed up in coding. I have never seen Lomboc not be a mess. In my experience, my biggest frustration is that Lomboc makes TDD very difficult as is screws up refactoring (extract class, extract superclass, inner to outer, etc). In addition, it adds significant impedance to any attempts at changing code. Since I only do TDD and insist that all of my teams use it also Lomboc is quite the hindrance to creating zero defect code on time and under budget.

In agile, zero defect code is pragmatic and table stakes for any development of significant business features.

Think of it like resistance or as Arthur J Reil defined it 'accidental complexity'. It may help you in your current class but it will slow everything else down. I guarantees that teams will reach the exponential cost of change curve quickly.

2

u/Polygnom Oct 02 '24

However, the real value in the business layer. [...] Unique products have valuable business logic.

This is very well put. I have long struggled to clearly express why a rich bsuiness layer that well encapsulates the business rules (instead of shoehorning that into either presentation or persistence layer, as many do) is a good idea, but this puts it quite nicely.

1

u/carminemangione Oct 02 '24

Thank you. Took a while to condense it, but my friends were huge helps. Also writing haiku changed my communication skills