Coder Social home page Coder Social logo

别什么都是 继承 about refactoring-kata HOT 1 OPEN

aikin avatar aikin commented on July 23, 2024
别什么都是 继承

from refactoring-kata.

Comments (1)

aikin avatar aikin commented on July 23, 2024

类名要简单,易懂。子类名有两重职责,不仅要描述这些类像什么,还要说明它们之间的区别是什么。类名,为了让代码可以更好的和人沟通,而不是计算机沟通。

继承虽然可以减少代码量,会比原封不动地把超类的内容复制粘贴到所有子类精简得多。和所有减少代码量的技巧一样,它会让代码变得更难读懂;*因为必须理解超类的上下文,然后才能有可能理解子类。*

每一次的增加间接层,都会增加理解的成本。因为需要了解这层抽象,才能知道如何完成下一个具象。

减少类的数量是对系统的改进,只要剩下的类不因此而变得臃肿就好。

from refactoring-kata.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.