ASP.NET Core Architecture - Classes for handling specific task
When developing an ASP.NET Core web app usually you have concepts like Controllers, Services, Models etc, that you keep in separate folders.
In my project I have some specific requirements: I've some cameras continuously acquiring frames and, from time to time, the software needs to generate a video from such frames. I'd like to use a dedicated class for handling recordings indexing, writing etc.
I've called this classe RecordingsService, but it could be just a static class since it isn't required to keep any state.
How should I consider this class? a manager for a specific task? a service?
12 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ok, I was just trying to understand where this logic should go from the point of view of a standard project organization
sounds like a service class, register it as a singleton
don't do statics for services, unless you like pain when you need to refactor all your callsites
Ok, I was exactly trying to understand if it was an abuse to make a service out of this class
Ok, it's just that a thought that a service was needed when I need to inject other services into the given one and to keep a state and I was afraid it was an abuse to create a service for this task
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Definitely a service class, and you can use
BackgroundService
if it has to run parallel to your web application and be able to do stuff in the background.Ok, thank you very much to all of you, that was a very productive exchange of opinions
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
So you'd instead use a service for each one of these task? it seems a bit too much imho
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
eheh indeed
you can put it all in one class to start with, and break it up as you need to