User:Jeroen De Dauw/Static: The S in STUPID/5

From semantic-mediawiki.org

The S in STUPID

Tight coupling!

public function doStuff() {
    // ...

    Logger::log( 'doing stuff during caturday is madness' );

    // ...

    DataStore::saveObject( $object );

    // ...
}
class DataStore {

    public function saveObject( $object ) {
        $loadBalancer = LoadBalancerFactory::getInstance();

        // ...

        $database->update( /* ... */ );

        // ...

        Logger::log( 'done saving object' );
    }

}
  • You cannot use a part of the system without initializing whole chuncks of it
  • Hard to fix once pervailent through the codebase