0

I'm working on a relatively big Android project. This project's app architecture is MVVM, and all layer responsibilities are separated well enough. Still, as this project is getting bigger, it's hard to maintain some, especially UI-related classes. I wonder if there is a better way to handle and shrink the UI class size in the number of code lines (nearly 2500 lines)?

  • ex: SinglePostFragment contains all UI-related logic like ( file download status, file type behavior ( pdf, audio, image, video ), like, bookmark, share, showing suggested list as a horizontal list, comments, etc.).
3
  • 1
    2500 is indeed too many lines for a single class. In your SinglePostFragment you can always split the logic depending on the functions you need for downloading files & its status, file type behaviour (split different actions depending on file types), etc. Showing suggested list & comments is something that can definitely be split up from the same Fragment to other use cases.. Commented Sep 7, 2022 at 12:31
  • @DarShan can you explain more about "other use cases" in your comment, please? Commented Sep 7, 2022 at 17:37
  • 1
    Example like create a separate BottomSheetFragment & a helper to load/manage comments & other related actions. So instead of handling everything in the fragment, you could move the comments handling to other UI classes & helper/utils classes. Commented Sep 8, 2022 at 9:49

1 Answer 1

1

Don't group code by it's type. For eg. folders like ViewModels, Activities, Fragments etc.

You should group it by its functionalites like loginScreen, homeScreen, chatScreen. Each part contains everything which is requrired to run it. Also apis list can be distributed according to it.

By the way this is also recomended by google for android development but not able to find it's link. Sorry about that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.