C
C#

help

❔ How would you write this service better?

Aantimatter81893/11/2023
The service:
Pphaseshift3/11/2023
for starters I wouldnt return null to something expecting a list
Aantimatter81893/11/2023
can you point me to the method where? where am i returning null? 😮
Pphaseshift3/11/2023
GetUserLessons
Aantimatter81893/11/2023
oh yeah thats a mistake for sure , thx. see anything else?
Pphaseshift3/11/2023
Why do you have a repository and cache a list of lessons?
Aantimatter81893/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
Aantimatter81893/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? what do you mean? repo only performs db operations it doesnt save an in app state
Pphaseshift3/11/2023
db is for saving state. wdym
Aantimatter81893/11/2023
Yeah but if if i dont want to make a db call each time smth happens on the ui I can work on the fields and only save to db when needed no?. or its the wrong way Like for example a user went into a lesson and didnt start it, why would i load it from the db? no changes happened Or if he gave no answers 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 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.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ Passing around thread to perform work on?I'd like to call a method that runs on the main thread but offloads a portion of it's work onto a paClass library, cant connect to console appHello! First time trying this so dont know how to fix or whats really wrong. - any ideas?❔ Auto PropertiesSo i have a property of Client, which has some properties of its own. One of which is ClientId. Some❔ Split on new line preserving empty lineSo I'm trying to create a method that given a string with `Environment.NewLine` or `\r\n` or `\r` or✅ Proper way to download a file in .NET MAUI?New to MAUI and I was wondering what the ideal way to download a file (YAML manifest) would be. Als❔ Flip Board not working properlyHello, I'm working on a level editor for my game. My board is not flipping properly. I've attached ❔ Misused header nameHi, I get the following error and I'm not sure on how to fix it. ``` System.InvalidOperationExcepti❔ Is there a way to name an object with an input?up❔ Visual StudioMy package manager console is not opening up, its tuck on initializing powershel host for almost 15 ❔ ERD ReviewI'm working on an ERD for the FE mockups here: https://imgur.com/a/E3XJ0OU. It's a multi-tenant data❔ How to reference older versions of system.windows.forms?Hello all. Daft question: how do I choose what version of system.windows.forms my project compiles w❔ when is it appropriate to use a linked list over a normal list ?Ive been bumping my head on linked lists for a day now, not really focusing on studying linked lists✅ Event-like event for ReadKeywith Console.ReadKey, the entire program waits for an input before continuing. is there a way to hav✅ Outputting values from a listWhen typing in name and age it doesnt display the correct values. Instead it outputs: Program+PersonForcing user to choose 1, 2 or 3Hello, im a bit lost! first is a while-loop to make sure input is not null, but then how would I bes✅ Storing JSON and User data in a multi-tenant applicationHello! I'm developing a multi-tenant (multiple concurrent users) application. I require a database f❔ Deploying a dotnet core application with DockerI'm mostly used to building NodeJS applications where during development, I keep all "secrets" and a✅ Regex which matches strings containing things other than specific patternsThis is probably a very weird question (and also isn't strictly related to C#). I need a regex which❔ Is saving data from DB into private fields is a good idea?Lets say i have this class: ``` public class LessonAppService :ApplicationService, ILessonServi❔ .net 7, net 7.0.3 compatibility issues? in dockerI have following issue: i'm trying to run my application in docker, but it complains that i have no