User:Jeroen De Dauw/Single Responsibility Principle/041

From semantic-mediawiki.org
Jump to: navigation, search
Jeroen De DauwJeroen De Dauw/Single Responsibility PrincipleUser:Jeroen De Dauw/Single Responsibility Principle/041

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