Today,I found this gem:

static function getConfig(){
$cacheKey = 'foobar';

try {
$config = $this->repository->getConfig();

$this->cache->set($cacheKey, $config);
catch(Exception $e){
$config = $this->repository->getConfig();

$this->cache->set($cacheKey, $config);
catch(Exception $e){}

I don't want to live on this planet anymore...!

  • 7
    That's the code equivalent of compiling again without changing anything, hoping that it will work this time
  • 1
    And of course there was only indirect unit-testing because of unit-tests of classes which use the configFactory.

    And of course I will refactor the shot outta this factory class ^^
  • 1
    Classic example of learning programming patterns, while neglecting the fundamentals
  • 4
    Might aswell use recursion until it would work 😂
  • 0
    One say:
    "It ain't stoopid, if it works!"

    I say:
    "Stfu! Go refactor and cover your unholy piece of code"

  • 2
    I hate it when people treat machines like everything else they do. Machines are deterministic. They are not dogs, cats or other pets. You don't ever "save again, just to be sure." If it didn't work the first time, it's not going to work the second time, and if it does, you've got some serious race conditions in there.

    Beware code that's like




    save(); //Just in case

    No! Stop that!.
  • 1
    What was Einsteins definition of insanity, again?
  • 0
    what language is this...?
Your Job Suck?
Get a Better Job
Add Comment