Allow dependency injection on the PackageManager
We want to allow one to provide their own PackageManager instance.
There are 3 standard ways of doing this:
1) Provide an instance in the constructor;
2) Provide a template parameter;
3) Use a hook that is called by the constructor;

We are going with option 3 as the other two methods have clear downsides:
Option 1 exposes too much of the implementation detail (even if it can
be wrapped by another constructor) and makes the dependency to internal
state hard / impossible (we need to instantiate SpecialDirs then load
the config that may modify SpecialDirs).
Option 2 is even worse as it exposes implementation details to the type
and makes OOP impossible (e.g. method accepting a `PackageManager`
need to be changed). Option 3 is the best compromise, as its main downside
is that it requires to create a new `Dub` type, however that is already
required due to the amount of configuration points that do IO
(loadConfig, determineDefaultCompiler, computePkgSuppliers).
1 parent e02314c commit 94cb94ceae107d200da91ba0fe6545170a39f840
@Mathias Lang Mathias Lang authored on 22 Dec 2023
Nicholas Wilson committed on 27 Dec 2023
Showing 1 changed file
View
source/dub/dub.d