nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

Restrict ViewModel visibility to `internal` within feature modules

Open audgns10 opened this issue 4 months ago • 5 comments

Summary

All ViewModel classes across the project are currently declared as public, even though they are only used within their respective feature modules. This can lead to unintended usages across modules and violates encapsulation principles.

Proposal

Change the visibility modifier of each ViewModel from public to internal if it is not used outside the module it belongs to.

This adjustment:

  • Prevents accidental access from other modules
  • Reinforces module boundaries
  • Keeps internal logic private to its domain
  • Makes the codebase more maintainable and intention-revealing

Example

// Current (public by default)
@HiltViewModel
class BookmarksViewModel @Inject constructor(...) : ViewModel() {
    ...
}

// Suggested
@HiltViewModel
internal class BookmarksViewModel @Inject constructor(...) : ViewModel() {
    ...
}

audgns10 avatar Aug 01 '25 15:08 audgns10