It pretty much makes sense to me of using interface with method signature/events and so on.
But, I am not able to find what's the use case for using interfaces with just properties
. ( I know properties are methods under the hood and they encapsulate and you can write some code on get/set accessor
and such.
What I'm behind is the use case
for interface with properties which acts like fields. (just get and set values)
.
For example, if I have interface with methods, I could use different implementations at run time, has advantages using polymorphism, pass different implementation based on interface contract, and it's easier for me to mock for unit tests. But if I have a class and I know it will just contain properties (like DTO). Why would I want to create an interface for DTO class? Is there any use case?
I tagged java because this is not a technical question and they have mutator method similar to get/set accessor.
Thanks.