Is Inheritance really needed?

后端 未结 22 2122
孤街浪徒
孤街浪徒 2020-12-14 00:20

I must confess I\'m somewhat of an OOP skeptic. Bad pedagogical and laboral experiences with object orientation didn\'t help. So I converted into a fervent believer in Visua

22条回答
  •  天命终不由人
    2020-12-14 01:04

    I think asking for situations where inheritance is really needed is missing the point a bit. You can fake inheritance by using an interface and some composition. This doesnt mean inheritance is useless. You can do anything you did in VB6 in assembly code with some extra typing, that doesn't mean VB6 was useless.

    I usually just start using an interface. Sometimes I notice I actually want to inherit behaviour. That usually means I need a base class. It's that simple.

提交回复
热议问题