android10 / android10/Android-CleanArchitecture
Should repositories know about authenticated user?
- Lingua principale
- Java
- Stelle
- 15.5k
- Fork
- 3.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In my project, I need to fetch some data related to the authenticated user, and for that I need the `userId` of the user. I have an `AuthManager` class that gives me the `userId` of the authenticated user. I am confused whether to add this `AuthManager` class as a member of my `UserRepository` implementation, or just get the `userId` from `AuthManager` outside the repository and provide it when needed. Basically I have 2 options.
**Option 1:**
Add `AuthManager` as a member to the `UserRepository` implementation. `UserRepository` will contain functions like `getAuthenticatedUserFirstName()`, `getAuthenticatedUserLastName()` etc. In the implementations of these functions use the `AuthManager` to get the necessary `userId` internally.
**Option 2:**
Leave out `AuthManager` from the repository. `UserRepository` will contain functions like `getFirstName(String userId)`, `getLastName(String userId)` etc. When calling these functions, use the `AuthManager` to get the required `userId` parameter.
Looking for feedback and suggestions.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Non vengono indicati file, test o punti di ingresso. Inizia esaminando i confini tra AuthManager e UserRepository descritti nell’issue, quindi confronta i due design proposti; il lavoro sarebbe concluso quando fosse stata concordata una direzione architetturale, anziché con una modifica specifica al codice.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, java
- Ambito
- mobile-dev
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100