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

From semantic-mediawiki.org

The S in STUPID

  • Static calls to leaves in the call graph are less evil
  • Leaves can stop being leaves
class Awesome {

    public function calculateAwesomeness() {
        Utils::getAwesomeFactor();

        // ...
    }

}
class Utils {

    public static function getAwesomeFactor() {
        return 42;
    }

}
  • What if the awesome factor is now stored in a config file or db?