DI and Simple Code #185
-
|
Hi, I wrote the following code to learn Dependency Injection. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
What do you mean by "is it true"? I just would rename the |
Beta Was this translation helpful? Give feedback.
What do you mean by "is it true"?
Regarding dependency injection - yes, you inject the
EmailServicewich implementsIEmailinto theEmailclass. You can create different providers implementingIEmail(e.g. a test provider, a provider using SMPT, a provider using Office 365...), and use all these with yourEmailclass.I just would rename the
IEmailinterface toIEmailSender. WithIEmailI would think more about the email content such as addresses, header, content...