Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor com.vaadin.flow.data.binder.Binder #20780

Open
mshabarov opened this issue Dec 23, 2024 · 0 comments
Open

Refactor com.vaadin.flow.data.binder.Binder #20780

mshabarov opened this issue Dec 23, 2024 · 0 comments

Comments

@mshabarov
Copy link
Contributor

Describe your motivation

Binder class is a hotspot and has code health index = 5 out of 10 (Problematic), thus needs a refactoring.

Modularity Issue
Binder has a total of ~167 functions, which put it at risk of evolving into a Brain Class. Brain Classes are problematic since changes become more complex over time, harder to test, and challenging to refactor.

Complex Method
7 methods have high complexity:

  • bindProperty(cc = 22)
  • writeRecord(cc = 18)
  • doWriteIfValid(cc = 13)
  • validate(cc = 11)
  • Binder.BindingBuilderImpl.bind(cc = 10)
  • doWriteDraft(cc = 9)
  • Binder.BindingImpl.execute(cc = 9)

A Complex Method has a high cyclomatic complexity. The recommended threshold for the Java language is a cyclomatic complexity lower than 9.

Complex Conditional

4 methods have complex conditionals.

  • bindInstanceFields:3686(3 complex conditional expressions)
  • Binder.BindingBuilderImpl.bind:1150(2 complex conditional expressions)
  • Binder.BindingBuilderImpl.withValidator:1182(2 complex conditional expressions)
  • Binder.BindingImpl.initFieldValue:1535(2 complex conditional expressions)

Inner classes and interfaces
Implementation inner classes can be extracted onto the outer new class in a backwards compatible way.

Additional context

See CodeScene analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Internal Backlog / Technical Debt
Development

No branches or pull requests

1 participant