To explain my problem, let me show you the example code with C#.
//ConstructorInfo is System.Reflection.ConstructorInfo class.
ConstructorInfo SelectConstructorInfo(Type declaringType);
private readonly ConstructorInfo _constructorInfo;
public TestClass(IConstructorInfoSelector constructorInfoSelector, Type type)
//Let the line to (A)
_constructorInfo = constructorInfoSelector.SelectConstructorInfo(type);
public TestClass(ConstructorInfo constructorInfo)
_constructorInfo = constructorInfo;
public Type GetTypeForConstructor()
//Let the line to (B)
public void DeosThisVoliateTheLoD()
IConstructorInfoSelector concreteSelector = ...;
Type testType = ...;
var selectConstructorInfo = concreteSelector.SelectConstructorInfo(testType);
//Let the line to (C)
var testClass = new TestClass(selectConstructorInfo);
var result = testClass.GetTypeForConstructor();
If one object depends on the behavior of another object supplied by a third object you violate LoD. The populistic verion of which is "Don't trust a friend of a friend"
In your second example you have another object depending on an object supplied by a third party so yes that does violate "don't trust a friend of a friend" except if
selectConstructorInfois only ever used for it's value.
It's worth to note that LoD was created for a specific project (Demeter) and that it in it's strictest form might not apply to any other project.