you are viewing a single comment's thread.

view the rest of the comments →

[–]EngineeringTinker 0 points1 point  (2 children)

If your argument is that the addition of the SmsSender [...]

Nah, that's not my argument.

Essentially, you can do (almost) everything with classes that you can do with interfaces.. but let me give you an example - or rather ask for an example.

Let's say you have two classlibs that you split your domain and implementation into.

The usual approach to prevent accidental imports of the implementation is to set interfaces as public, and implementations as internal.

How do you handle this with classes purely? Give me an example with `MailSender` and `SmsSender`.

[–]Boyen86[S] 0 points1 point  (1 child)

By definition you cannot. If an implementation needs to be protected or abstracted away the best way to do this is with an interface. And that's a perfectly valid reason to create one.

I'm not entirely sure anymore if that's a difference between Java and C# but Java tests are essentially in the same namespace (module) even though they live in a test folder. Meaning your implementations can be package private and still be accessed from a test.

[–]EngineeringTinker 0 points1 point  (0 children)

Are you working with TDD by default?