Uploaded image for project: 'Apache Fineract'
  1. Apache Fineract
  2. FINERACT-1586

Reduce Boilerplate Code by Introducing lombok to Reduce getters/setters and Mapstruct to map REST DTO to Entity Objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Minor
    • Resolution: Unresolved
    • None
    • 1.11.0
    • None

    Description

      Lombok could help us to not only reduce a large amount of code, but also to fix a couple of inconsistencies in the code base:

      • getters/setters with non-standard characters (e. g. underscores)
      • getters/setters with typos

      The layered architecture of Fineract requires mapping between REST DTO classes and internal entity classes. The current code base contains various strategies to achieve this:

      • private functions
      • static functions
      • mapping classes

      All of these approaches are very manual (and error prone) and difficult to maintain. Mapstruct can help here:

      • throw errors at compile time (missing new attributes, type changes etc.)
      • one common concept (easier to understand)
      • reduce manually maintained code and replace mostly generated code

      Challenges:

      • maintain immutability (especially in DTO classes)
      • should we fluent builder pattern?
      • backwards compatibility
      • these improvements cannot be introduced as one pull request, but have to be split up at least at the “module” level (clients, loans, accounts etc.). This would result in approximately 30 pull requests; if we split up Lombok and Mapstruct then it would be 30 PRs each (=60); we would need this fine grained approach to make a transition as painless as possible
      • some classes are maybe beyond repair (e. g. Loan.java with 6000 lines of code, the smaller part getters/setters and a long list of utility/business logic functions)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rahul.usit12 Rahul Goel
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: