I don't think it does, I mean the method sets a default path, and if none is given uses a default one.
Nov 9, 2024
4
Level 1
Balancing SOLID with Real-World Constraints
I'm looking for some insights on a fairly academic point, but it's been on my mind as I think through some design choices. In a service class, I’ve used ?? config to set a default path if none is provided, like in this example
public function __construct(
protected FetcherInterface $imageFetcher,
protected StorageInterface $storage,
string $imageStoragePath = null
) {
$this->imageStoragePath = $imageStoragePath ?? config('paths.image_storage_path');
}
I’m debating whether this might break SRP or dilute dependency injection principles a bit, though it seems more convention-based. With more extensive experience, do people find this kind of config-driven fallback practical in bigger projects, or does it turn into a source of tech debt? Curious if this is something others think about in large-scale apps, or if it’s just a matter of pragmatism versus purity in design.
Please or to participate in this conversation.