In android development with uncle bob's clean architecture, what package i should put my…
- User
In android development with uncle bob's clean architecture, what package i should put my "MusicWorkManager" and "MusicForegroundService"
- Assistant
In android development with uncle bob's clean architecture, what package i should put my "MusicWorkManager" and "MusicForegroundService"
According to Uncle Bob's Clean Architecture principles, your application should be organized into layers that separate concerns and reduce dependencies between different parts of your code. In Android development, these layers can be represented as separate packages or modules. Here's how the layers are typically structured:
Given that, your MusicWorkManager and MusicForegroundService are both tightly coupled with Android framework components:
MusicWorkManager: An implementation using Android's WorkManager API for background work.MusicForegroundService: An Android Service that runs operations in the foreground.Both classes are part of the Frameworks and Drivers layer because they deal directly with Android-specific APIs and components.
Recommendation:
framework, android, platform, or services.service subpackage and workers in a worker or workmanager subpackage.Example Package Structure:
- com.yourapp
- domain
- entities
- usecases
- data
- repositories
- datasources
- presentation
- viewmodels
- views
- framework (or android/platform/services)
- service
- MusicForegroundService.java
- worker
- MusicWorkManager.java
Summary:
Place your MusicWorkManager and MusicForegroundService classes in the Frameworks and Drivers layer of your project structure. This keeps your framework-dependent code separate from the business logic and application rules, adhering to the principles of Clean Architecture.
Additional Tip: Ensure that your inner layers (domain and data) do not depend on these framework-specific classes. Instead, use interfaces in the inner layers and have your framework classes implement these interfaces. This approach maintains the dependency rule and keeps your business logic independent of the framework.
Answer: In the Frameworks and Drivers layer—the outermost layer—so place them in a package dedicated to framework-specific implementations, like framework or services