SOLID Principles

  • Single Responsibility

    • CityPair
    • CityPairConverter rather than add convert method inside CityPair
  • Open for Extension, Closed for Modification

    • Policy
    • NfdPolicy extend Policy, add FareBasis field
  • Liskov Substitution

    • Policy interface should not have getFareBasis method, because fdPolicy has no farebasis
    • any implementation of an interface should not break our code, like throw UnsupportedOperationException
  • Interface Segregation

    • Split BearKeeper into BearCleaner, BearFeeder and BearPetter
  • Dependency Inversion

    • Computer-StandardKeyBoard, bad
    • Computer-KeyBoard-StandardKeyBoard, good
posted @ 2022-12-30 20:29  rxh1999  阅读(29)  评论(0)    收藏  举报