C
Join ServerC#
help
❔ How would you write this service better?
AAntiMatter3/11/2023
The service:
Pphaseshift3/11/2023
for starters I wouldnt return null to something expecting a list
AAntiMatter3/11/2023
can you point me to the method where?
AAntiMatter3/11/2023
where am i returning null? 😮
Pphaseshift3/11/2023
GetUserLessons
AAntiMatter3/11/2023
oh yeah thats a mistake for sure , thx.
see anything else?
see anything else?
Pphaseshift3/11/2023
Why do you have a repository and cache a list of lessons?
AAntiMatter3/11/2023
Yeah thats what i was wondering about, whats the best practice for this?
Pphaseshift3/11/2023
don't have two things for the same state
AAntiMatter3/11/2023
I mean if i load all user related lessons i can just place them in a private field and work on them no?
AAntiMatter3/11/2023
what do you mean? repo only performs db operations
AAntiMatter3/11/2023
it doesnt save an in app state
Pphaseshift3/11/2023
db is for saving state. wdym
AAntiMatter3/11/2023
Yeah but if if i dont want to make a db call each time smth happens on the ui
AAntiMatter3/11/2023
I can work on the fields and only save to db when needed no?.
AAntiMatter3/11/2023
or its the wrong way
AAntiMatter3/11/2023
Like for example a user went into a lesson and didnt start it, why would i load it from the db? no changes happened
AAntiMatter3/11/2023
Or if he gave no answers
AAntiMatter3/11/2023
so why read a non changed entity from the db ?
Pphaseshift3/11/2023
SetActiveLesson - that's just setting some kind of ui state, but yet its making repo calls as well
Pphaseshift3/11/2023
It's not clear what is transient/ui data and what is permanent/repo data
Ppox3/12/2023
db reads are not that expensive, normally you want to avoid using a cache
AAccord3/13/2023
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.