33
Mb3leb
6y

Working code is not a clean code

Comments
  • 2
    I don’t give a fuck. If it works I don’t touch.
  • 1
    @dudeking eum not a must
  • 1
    @Biggy you have to, just in case
  • 7
    My code doesnt work. That means its clean. Thank you.
  • 10
    Sadly lots of people don't care about clean code, they think about current task, it works then we're done.

    This will always produce legacy un-maintainable systems which future devs will rant about :)

    We should always try to make best out of two (of course working, but clean code needs to be taken into account)
  • 3
    wait.. clean code and working code arent opposites?

    Throw into mix DRY, SOLID and some other paragdims and you end up in broken hell of cleannes.

    week ago or so I was DRYing my POC code.

    Oh boi, it began to be so difficult to understand what's going on. When I squashed it, I was left no option but either:
    -un-DRY it a little
    - make really long function names (ie. authUserAndSanitizeInputAndPrepareModelsAndRespondOnFailure())
    - make nice short function names where reader is clueless what the actuall fuck that does without digging deeper (ie. prepare() )

    so I ended up in starting point but with DRY obfuscation (ended up with mix first and last option and "prepare" ended up "canContinue")
  • 2
    @DubbaThony DRY can be a little tough to achieve, as for SOLID, I mostly rely on S and O, I try as much as possible not edit already tested classes, and make sure it has its single responsibility. As for DRY, like everyone else I just create a new function that calls the old one, and then do extra work, unless that extra work to be executed at the middle original execution.

    That long named functions are annoying and I do what you do, end up having it spread out and repeated rather long bloated names
  • 2
    to add on what @NoMad break it down and give a new function: executeXProcedure();

    But @NoMad, I sometimes face his same scenario, not sure where I went wrong :\
  • 1
    @NoMad

    But than its anti-DRY

    I had it but I had same code in around 10 places.

    E:

    and worth mentioning it was annoying that in this file that totaled a little bit over 50 lines of code I was having +- 40 lines of repeated code
  • 2
    Similarly, clean code is not always working code.
  • 2
    @bhumish but I guess you understood my point
  • 0
    @JustThat

    Clean and working..... Hmm... Intresting concept ;)
  • 0
    Clean doesn't mean it works either.
  • 0
    @JustThat Well, thats true. Also performance likes to suffer a bit.
  • 0
    @JustThat oh boi, becouse hell, its choice clean or performant. Thats not "influence". Its killer. Take PHP for example. If you have 20 simple classes you could merge into 2 classes there is great chance you will gain much, much perfromance becouse every file counts for IO operation.

    And thats just separating files argument, bot to mention abstraction layers etc.

    IO is a thing to point where there are "compilers" out there that merge your php code into 1 file (not a joke)

    Edit: sorry, i hate unnesesary abstraction layers and thats one of my arguments and it triggered that part of the brain
  • 0
    @JustThat it helps improve code but its output is.... Not clean by any, any means. Try to navigate on say 1MB file ;)
  • 0
    BS. Just came home from work, producing code that's both.
  • 0
    @JustThat Python 😊
Add Comment