zhongkouwei
V2EX  ›  问与答

继承 or 组合

  •  
  •   zhongkouwei · Jan 8, 2018 · 1808 views
    This topic created in 3078 days ago, the information mentioned may be changed or developed.

    刚在一个问题下看到有人说这个,我也有同感。 在学习的时候面向对象的三大特性继承封装多态被强调了无数遍,但是实际编程中好像更多用的是对象组合。可能没设计好,感觉继承不太容易复用。大家平时都是怎么设计呢?有没有大佬讲一下

    SoloCompany
        1
    SoloCompany  
       Jan 8, 2018 via iPhone
    effective 系列中的有关代码复用原则之一:复合优于继承
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2380 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 00:42 · PVG 08:42 · LAX 17:42 · JFK 20:42
    ♥ Do have faith in what you're doing.