FraznoFire
Explore posts from serversNaming factories “class”factory always a good idea?
Hi everyone,
I’m just learning about design patterns, and all code examples I’ve seen highlight their implementation with obvious examples such as “DogFactory” etc.
I’m wondering if this is usually done in practice, or if the class name should instead represent its purpose in the code, for example:
A factory class that resolves the manufacturer of an item from its properties, and returns that manufacturer’s specific implementation of IVendorThing, would I name that factory “VendorThingFactory” or something like “VendorThingResolver”?
10 replies
Return Value on Entity Modification
Hi everyone, I'm creating a class library that contains my entity framework models and surrounding business logic for my project. I am creating a method for modifying one property of my entity. I am wondering if it is best practice to have this method return the entire object, a bool for success/fail, the changed value, or nothing.
My thinking is that since the method is being passed a reference to the entity stored in the database, I shouldn't have to return the full entity as the change has been saved, but I just don't know what sort of standard to apply in my code and if it will have any negative cosequences in the future of the codebase.
7 replies
Best practice for Database EF Migrations (Auto v Manual)
Hi everyone, I have written an API in ASP.Net that connects to a postgresql database. I have so far setup Github Actions to automatically push new releases to DockerHub, and have my host run checks for new versions to pull down.
The next part I am looking at is the database, if I add an EF Core migration, what is the best way to apply this to the database? I understand I can have this migration compiled into a standalone binary that connects to the DB and applies it, or can have it deployed as a .sql script. I am unsure what is the best way to go about A) SQL script or standalone binary to apply migration, and B) do I set it up to apply migrations entirely automated whenever a new one is required, or is that bad practice in production?
I currently have the API configured to apply the migration to the DB on startup, but given I am trying to design this as if it is a production system that has multiple instances of the API running, I think it would be bad practice for them to all try and apply a migration at once.
27 replies
Azure Table Client Query Filter not evaluating correctly
Hi everyone, I am building an app with Azure Functions written in .NET 8, and one part of the app is a cleanup function that deletes items older than 1 week, but when I query the table for items older than one week, it doesn't return anything, despite verifying that there are multiple entities in the table with timestamps older than a week, I have confirmed removing the filter returns all items, so there is something wrong with the expression itself, but I can't figure it out for the life of me.
The snippet of code is as follows:
1 replies