Service Location
Our current implementation of the MailService class relies on the calling code to create an instance of the ISystemSettings interface, and pass this through in the constructor. When we write code that creates an instance of the MailService class, we are therefore forced to provide the ISystemSettings interface at the time of construction. This is a compile-time dependency. In other words, changing the instance of ISystemSettings requires changes to the source code, and then recompilation. It would be far better, however, if we set these options at runtime.
In order to accomplish this, the MailService class needs to request an instance of the class that is implementing the ISystemSettings interface at runtime, not at compile ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access