❔ Question about abstraction
Is this a correct usage of interfaces? then having
implement an abstract class an and interface
10 Replies
or should the method not be implemented and then implement in class extending it?
Interface with method implementations? 🤯
interfaces describe contracts -> behavior of something, so it fits.
base classes and alike are implementation details, which seems to fit here as well.
with this little piece of code w/o further context it seems fine
iirc default interface method implementations were added in c# 8.0
I think this is an anti-pattern for most use cases.
i think its a totally fitting use case here
the other option is copying the code in 5 places
as long as the actual
ILocatable
type isnt volumetric that method is accurateI usually view default interface implementations as "mixins", I don't use them a lot, but there are good use cases since the alternative is either duplication or often using an abstract class which in turn causes issues if your class already inherits from another one
tbh i think this is a really good example for the usage of default interface implementations 😂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.