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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#159OP3y ago
Ok, I was just trying to understand where this logic should go from the point of view of a standard project organization
Trinitek
Trinitek3y ago
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
alkasel#159
alkasel#159OP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
SuperBrain
SuperBrain3y ago
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.
alkasel#159
alkasel#159OP3y ago
Ok, thank you very much to all of you, that was a very productive exchange of opinions
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#159OP3y ago
So you'd instead use a service for each one of these task? it seems a bit too much imho
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
alkasel#159
alkasel#159OP3y ago
eheh indeed
Trinitek
Trinitek3y ago
you can put it all in one class to start with, and break it up as you need to

Did you find this page helpful?