https://kotlinlang.org logo
n

Nishoobansal

07/03/2020, 3:56 PM
can somebody explain me the difference between inheritance and implementation and how they affect the memory of system?
m

manlan

07/03/2020, 4:32 PM
What exactly do you mean by implementation?
a

ariRG

07/03/2020, 5:11 PM
@Nishoobansal by implementation if you mean implementing interfaces, then the question is not about inheritance and implementation, it is about the difference in the concept of inheritance from classes and interfaces.
n

Nishoobansal

07/04/2020, 1:53 PM
Thanks for the help but I understood now. 👍
👍 1
m

Matteo Mirk

07/06/2020, 8:22 AM
What you need to distinguish is the difference between “implementation inheritance”*(1)* (extending a concrete or abstract class) and “type inheritance”*(2)* (implementing an interface). (1) can be easily misused and lead to deep and brittle class hierarchies, while (2) is more flexible, because it describes roles or traits of your type, doesn’t force you to inherit implementation details and is to be preferred.