ipl-dashboard icon indicating copy to clipboard operation
ipl-dashboard copied to clipboard

Added lombok dependency

Open nirvana124 opened this issue 3 years ago • 5 comments

Added lombok dependency to reduce verbosity of code.

nirvana124 avatar Apr 12 '21 17:04 nirvana124

Hi @nirvana124 ! Nice improvement! I agree that adding lombok will decrease boilerplate code. But, I believe you are messed one thing here:

  1. MatchInput its just a POJO, it shouldn't know anything about conversion one entity to another
  2. You are misusing @builder(toBuilder) annotation in Team.java Best regards, Maks

@mvoronov Thanks for review.

If we are adding any method about conversion in POJO we can consider it as a class and not a POJO :) It increases the code readability but i think in this project we already have MatchDataProcessor for conversion.

Can you please elaborate on point 2 ?

nirvana124 avatar Apr 13 '21 11:04 nirvana124

Hi @nirvana124 ! Nice improvement! I agree that adding lombok will decrease boilerplate code. But, I believe you are messed one thing here:

  1. MatchInput its just a POJO, it shouldn't know anything about conversion one entity to another
  2. You are misusing @builder(toBuilder) annotation in Team.java Best regards, Maks

@mvoronov Thanks for review.

If we are adding any method about conversion in POJO we can consider it as a class and not a POJO :) It increases the code readability but i think in this project we already have MatchDataProcessor for conversion.

Can you please elaborate on point 2 ?

Hi @nirvana124 ! I mean why don't simply do like it was originally? Could you explain what is the benefit of using toBuilder in this piece of code?

Team team = this.teamRepository.findByTeamName(teamName);
return team.toBuilder().matches(matchRepository.findLatestMatchesbyTeam(teamName,4)).build();

mvoronov avatar Apr 13 '21 17:04 mvoronov

Hi @nirvana124 ! I agree with @mvoronov point here. For Team class creating a builder pattern is not adding any values. Normally if a constructor of a class becomes more complex (wherein it accepts more than 7 params), that is one of the scenario beneficial for Builder Pattern.

anshulbharadwaj avatar Apr 15 '21 09:04 anshulbharadwaj

Hi @nirvana124 ! I agree with @mvoronov point here. For Team class creating a builder pattern is not adding any values. Normally if a constructor of a class becomes more complex (wherein it accepts more than 7 params), that is one of the scenario beneficial for Builder Pattern.

Well, it also might be a true, but my point mainly was about "toBuilder" option.

mvoronov avatar Apr 15 '21 15:04 mvoronov

Thanks for your feedback :) Below are the reasons why I have used builder and toBuilder Builder: It makes code more readable, It removes verbosity. You can see in one single line for what parameters you are setting the values.

toBuilder: You can see there is a team object which is returned by repository. I used toBuilder on team object which is creating a new object and not changing existing team object. Team team = this.teamRepository.findByTeamName(teamName); return team.toBuilder().matches(matchRepository.findLatestMatchesbyTeam(teamName,4)).build();

nirvana124 avatar Apr 29 '21 15:04 nirvana124