Short version: when should I put something into app/services instead of into lib/.
I've been going down the service objects route recently, but I realised that sometimes I can't really decide weather I should extract something into a service object (which I have in app/services) or into a class in my lib folder.
One thing I usually look for is if the class needs access to params or other controller-specific things (i.e. as a param in the initializer), then I tend to put it into services.
What is the convention here? Proof (links) would be nice :)
This is how I tend to think about code that goes in lib/
:
lib/
is the first step in that direction.Services:
IMO, services are an abstraction of your domain. Lib stuff is for convenience classes, other stuff that doesnt directly relate to your models.
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