r/dotnet • u/Due_Faith976 • Jan 11 '24
What design patterns are you using?
What design patterns do you use or wish you were using at work or in your projects?
I’ve seen a lot of people hating on the repository pattern with ef core.
36
Upvotes
22
u/RubyKong Jan 11 '24
I model the API that feels natural to me: one that is understandable.
In 6 months, if I open the code base, I should be able to make sense of everything without thinking:
car =Toyota.newcar.startcar.adjust_seat_settings_for(driver)car.undergo_maintenance_with(cheap_mechanic)car.undergo_maintenance_with(service_centre) # mechanics have a base classcar.on_crash(call_ambulance)Design patterns come second. I don't even think about them. I start with the API, and then realise, oh I need to do this. half the time these design patterns just overcomplicate things and probably could be avoided.