官术网_书友最值得收藏!

Chapter 3. When Objects Are Alike

In the programming world, duplicate code is considered evil. We should not have multiple copies of the same, or similar, code in different places.

There are many ways to merge pieces of code or objects that have a similar functionality. In this chapter, we'll be covering the most famous object-oriented principle: inheritance. As discussed in Chapter 1, Object-oriented Design, inheritance allows us to create is a relationships between two or more classes, abstracting common logic into superclasses and managing specific details in the subclass. In particular, we'll be covering the Python syntax and principles for:

  • Basic inheritance
  • Inheriting from built-ins
  • Multiple inheritance
  • Polymorphism and duck typing
主站蜘蛛池模板: 荣成市| 璧山县| 岳池县| 永嘉县| 澎湖县| 广宗县| 荆门市| 山阴县| 双桥区| 凌源市| 湖州市| 玛曲县| 宁陵县| 池州市| 无棣县| 沙坪坝区| 灵山县| 永清县| 苍梧县| 资中县| 连城县| 舟曲县| 张家口市| 东方市| 无为县| 商洛市| 谢通门县| 阳原县| 许昌县| 南丰县| 五莲县| 胶南市| 揭东县| 永安市| 宁化县| 汉川市| 滁州市| 米林县| 密山市| 界首市| 临潭县|