Working code is not a clean code

  • 3
    I don’t give a fuck. If it works I don’t touch.
  • 5
    Working code and clean code are opposites most of the time
  • 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.
  • 11
    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)
  • 4
    Clean code is maintainable code with "enough" comments and "enough" modules.

    Clean code is about quality. While working code is about functionality. So the base for having clean code is functional code. You can have two lines of comment and a print and call it "clean" while in face its rubbish.

    You get what I'm saying? You cannot have clean code without the functionality being there.
  • 4
    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")
  • 4
    @DubbaThony so one function has three responsibilities? Break it down dude, or it will turn into hell in no time. One function should have one responsibility. If more, give it sub functions.
  • 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 :\
  • 2

    But than its anti-DRY

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


    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
  • 3
    Similarly, clean code is not always working code.
  • 2
    @bhumish but I guess you understood my point
  • 1
    First, make it work.
    Then, make it work better.
    Then, have someone else clean it up. Holy shit, would you look at that mess! I mean, my god! What were you smoking when you wrote this? Did you even think about maintainability? You did? But you had tight, arbitrary deadlines to meet?


    Clean. Fast. Working. Pick two.
  • 1

    Clean and working..... Hmm... Intresting concept ;)
  • 0
    Clean doesn't mean it works either.
  • 1
    @DubbaThony Oh, I'm sure it's possible but I think the first question one has to ask if asked to make code "clean and working" is "Is there enough time between now and when this project is invariably cancelled for me to do that?"
  • 1
    @JustThat Well, thats true. Also performance likes to suffer a bit.
  • 1
    @DubbaThony Great point. Clean code frequently has more moving parts than less-clean code does and there is an overhead cost for all that abstraction. Guess it depends on the language, though. In interpreted languages, I think clean would be the mortal enemy of performant.
  • 2
    @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
  • 1
    @DubbaThony I agree. I just understated my opinion for want of trying to not insult anyone.

    I once worked with a bunch of Rubyists who thought nothing of having a string of includes (6,7 or 8 levels deep) which ended in a file that contained nothing more than an instantiation of a variable as an object.

    I always thought that would be a drain on performance because of the I/O involved (in memory or on disk) of having to traverse that chain each time the code was called.

    Struck me as unnecessary.
  • 1
    @DubbaThony So...wait...a php "compiler" would take your clean code and make it "dirty"?
  • 2
    @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
    @VaderNT Language?
  • 0
    @JustThat Python 😊
Your Job Suck?
Get a Better Job
Add Comment