GithubHelp home page GithubHelp logo

phpdesignpattern's Introduction

PHP设计模式

面向对象的目标
  • 高内聚,低耦合
面向对象设计的基本原则
  1. 单一职责:一个类只做一件事
  2. 开闭原则:对扩展开放对修改关闭
  3. 里氏替换:子类必须能替换所有父类的使用
  4. 依赖倒置:设计依赖于抽象而不是实现
  5. 最少知识:对象应当尽可能少的去了解其他对象
  6. 接口隔离:接口倾向于小而多
  7. 组合优先:优先使用类的组合而不是继承

抽象类和接口的使用

  • 当类中有共同的行为或属性时,可以考虑使用 abstract calss
  • 当类别中有共同的操作界面,但是在实现上有所差别,可以考虑使用 interface

phpdesignpattern's People

Contributors

igo9go avatar

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.