-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improving the reusability and maintainability in ScrollbarExt.kt file and Fix the scroll bar thumb jumping a little bit due to lack of smothness on interpolatedIndex #1550
Conversation
Signed-off-by: Rodrigo Dias Ferreira <[email protected]>
...n/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/ScrollbarExt.kt
Outdated
Show resolved
Hide resolved
…t private instead of internal
Sometimes, I believe that dividing similar logic into multiple extension functions is done to reduce the learning curve of the logic. When I look at the refactored code, it seems that jumping from the extension function to |
Hi @yongsuk44, thanks for your comment making this discussion richer. Moreover, if there will be some need to fix something in that logic in the future, it won't be necessary to change on the 3 different functions, only in one place, which improves also the maintainability. Besides one could even forget to change on these other places, which would cause different behavior for the scroll bar for the different type. In summay, in my opinion, this refactoring is a good improvement for Now In Android code base in aspects of study, reusability and maintainability. |
Hi, So merging them into once might not be the best approach. |
Hi @anhtuannd , thanks for raising this concern. |
…s on interpolatedIndex Signed-off-by: Rodrigo Dias Ferreira <[email protected]>
2fd6bb4
to
31b77d5
Compare
Hi hi! Original author of the Scrollbar here. It used to have a generic abstraction, but we split up out for readability. You can see the original PR where the generic code was split up favoring readability over copy pasting here: #947 (comment) |
Hi TJ / @tunjid , how are you? I understand what you are saying, but on my opinion I still think that the generic abstraction eliminates some duplicated logic and improves the maintainability. And also I prefer to read the more concise code, which I know for sure that the parts that use the same generic abstraction, they are the same, no need to compare the code and checking that they do the same thing. But since you guys made this decision consciously, I will open a new PR with the fix on the commit: 31b77d5, and close this one. Thanks a lot for the feedback. :-) |
What I have done and why
Improved the reusability and maintainability of the file ScrollbarExt.kt file by implementing a generic:
<LazyState : ScrollableState, LazyStateItem> LazyState.genericScrollbarState
, and reducing the repetitive logic and code.Related issue: