Let's say my business layer currently contains a bunch of DTO's and separate service classes to communicate with the data repository.
Example:
class PersonService
{
IPersonRepository _personRepository;
ILogging _logger;
ICacheStorage _cache;
// Constructor here to create concrete objects.
public Person GetPersonById(int Id)
{
// error logging and caching here???
}
}
Does it make sense to log and cache at this layer? Or would it make more sense for an Application Service layer to handle these concerns? Or maybe something else altogether?
Caching can or should be implemented whenever possible. Also caching should be transparent, so anyone who uses it shouldn't know it is actualy used. Most of the time it's logical to put it inside a data access layer, but sometimes it is logical and possible to put it in business layer too.
Logging is IMO something, that doesnt belong in any layer. It should be application-wide with one access point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With