|
|
|
|
|
by xthrowawayxx
1475 days ago
|
|
In my experience I prefer grouping by domain over grouping by abstraction An ISaveable interface would need to be generic but "save" functions might take different numbers of arguments, and of different types. I've found the advantage of interfaces to be dependency injection, where i can inject a different implementation of an interface without breakijg anything (eg save to s3, to google cloud storage, to filesystem, to memory), or a test version of the function/class. Abstractions like ISaveable on the service interface just make the code more fragile in my experience in an attempt to save some extra but simple lines of code. Granted it may make sense on active record model classes though. |
|
I'm unsure about DI in general [1], but using the Objectifier-Pattern just to appease the DI-System is bad. Likely, you can use `Symbol()` to indicate how your code should be wired.
Decoupling your dependency seems reasonable, but you can do it much simpler.
Depending on the situation, I would go even further and inline the type definition: [1]: https://news.ycombinator.com/item?id=31547975 - I'd love to hear opinions on that.