User:Jeroen De Dauw/Single Responsibility Principle/041

From semantic-mediawiki.org

The single responsibility principle

The problems with violating SRP

  • Complexity increases
class MapsLocation {

    public function setCoordinates( $coordinates ) {
        // parse
    }

    public function setAddress( $address, $asActualLocation = true ) {
        // geocode
    }

    public function __construct( $coordsOrAddress = null, $format = Maps_COORDS_FLOAT, $directional = false, $separator = ',' ) {
        // ...
    }

    // ...

}
  • Harder to understand
  • More bugs