Just finished all the form function, time to clean up I guess.

Did you guys like to write it clean from start or do it later at the end?

  • 13
    Is there anyone waiting for the code?

    Do it fast and dirty. Functional, but ugly. While it's used, you can write a new version without impacting others work.

    Else, go as clean as possible. You never know who might work on it later. o/
  • 3
    What @DarkMelchiah said. I usually implement my stuff in the ugliest, and dirtiest, form possible, elegance be damned. So long as it works, and testers are not complaining how long some processing takes, I just leave it at the backburner until I get enough time to actually clean it up, optimize, etc.
  • 5
    @DarkMelchiah @monzrmango sometimes I feel bad, and my ocd just force to write it clean from the start until I’m really depressed or desperate
  • 9
    Usually I write stuff dirty first, then take a couple nights of sleep to cultivate how else I could write it, and then end up writing its refactored version 🙂
  • 6
    @Condor guess I need to learn how to be ignorant once in a while
  • 3
  • 5
    @Condor I mean sometimes when I write I know this is a wrong way to do it, but it worked. So I always stuck at it doing the right way instead of leaving it and come back later
  • 4
    @devTea I feel you. But it's something that you "develop" with time. You don't have to keep writing ugly code and stuff... It's just a resource you have when there's little time to deliver the MVP.
  • 3
    Depends on the deadline @devTea
  • 3
    @devTea nothing wrong with that line of thinking, it's especially encouraged in our line of work. Just need to balance how much time it will take for you to make something clean, simple, fast, and elegant versus how much time it will take for the project to be shipped with the spaghetti code. The fastest code is the one that hits the market earliest - my old boss's words.
  • 5
    @devTea ah, I see now. Well my stuff usually works and as far as I can tell I don't have any users and certainly not deadlines, so that could be the cause why my workflow is different from yours. Perhaps it's ignorance, perhaps it's lack of deadlines, laziness, or no financial incentive to work on it as much as I would if I were to get paid for it. Perhaps it's a bit of all that.

    If I were to make a professional product, I wouldn't release it until it's fully functional and clean though. Often times that means multiple iterations of the product and a long time of being a work in progress before I call it in any way stable.

    I would hate to sell a product to anyone if I know that it wouldn't be good.
  • 3
    @Condor That's actually a good point. - Most of times my work is not related to coding (which is weird, considering that I'm a CompSci guy), but to network log analysis. So when I'm actually writing code, it's for some automation tool to be used by another dev to help with some tasks - As it's something that won't actually go out of our technical group, making it beautiful usually is not a necessity - even tho we go through our code from time to time to reorganize it (I forgot the correct word to use here...).
  • 5
  • 3
  • 2
    I spend a bit of time thinking before coding. Clean it up as much as I can in my head then code. Once it's in the editor try to keep it clean as I go. Like a master chef will tell you "Mise en place".

    Code under construction is naturally going to be messier than the end product but it's easier to work on if you clean as you go along.
  • 1
    Write function, write test, pass test, rewrite function properly, test again to see if nothing’s broken, next step ;)
  • 1
    I try to make it clean from the start but always go back and clean it again after I'm done, never got it all clean from the first shot lol
  • 5
    @gitpush @Maartz @CodeMonkeyG

    I spent time too long thinking about it, fuck I hate myself
  • 1
    @devTea I’ve to admit that it’s really difficult to not write down directly what’s in my head.

    You shouldn’t feel bad ;)
    Have you tried TDD ?
  • 6
    @Maartz not yet, haven't heard that terms in my area. I'll google it later
  • 1
    @devTea its not only you, I too face this problem, but I try to create lots of tiny projects that cover one idea, for example how to structure my data layer, when I'm done with that I use my findings in a production project, so that I can see what is wrong with what I did, then go back and fix again ...etc. That's how I sort of teach my self to better code
  • 1
    @devTea My day is like 70% thinking and 30% actually putting code down but that brings my over all productivity way up because I'm not spending time writing and deleting code for the sake of seeing if it will work as expected.

    It is a challenge though to not end up in analysis paralysis.
  • 5
    I pushed my code to rehab
    It said noo noo noo
  • 1
    I give it my wife to clean my code.
  • 2
    It may be due to the fact that I do not program professionally yet (no deadlines :P), but I generally lay out good quality code straight away :) Feels much better imho
  • 1
    I always take it slow and write it clean.
  • 2
    Make it work - then make it pretty.
    Of course dont write shit code but you wont see the ideal solution (implying there is one) until you got it working most of the times. Also good IDEs help alot with refactoring
  • 4
    @Biggy what? lol

    @karma how I feel when getting out of bed on monday morning

    Well After hearing these from you guys maybe I shouldn’t worry too much, thanks
  • 3
    @devTea monday mornings should be deprecated 🙈
  • 1
    I usually go with iterations. Hack a function together, write tests, pass tests, tweak the function so it looks nice, pass tests and repeat for another component. I like quick results. And when it works, beautifying / optimizing it is usually pleasant 😁
  • 2
    I think that there's always room for improvement. Write code as good as you can given time constraints and abilities and go back to it after a while to make it gorgeous 😍
  • 2
    let s = speed of development ( or hours spent coding)

    let m = ease of maintenance


    rating scores of 1 .. 10

    s = 1, means took forever

    m = 1, means hard to maintain

    and so on

    in the beginning, all code is


    Right? cuz you'd want to write it quick, but you know it'll be hard to maintain.

    Just write naturally, whatever comes to mind, don't stress yourself, don't edit yourself, just make it work as best you know how.

    Once it's working, I take a break. But more importantly I accept it. When coming back to it the first time, I might end up with 3/8

    Then second session, 4/7 and so on.

    Repeat that until I'm happy with the code/functionality. Might end up with 7/4

    Sometimes it'll take a week to implement a major feature, but I had it working within 2 days.

    It will never be 10/1, and that's ok. And it'll never start off at 3/7 thats ok too.

    I think this made sense... lol just came up with it, tell me if errors please, going in book
  • 1
    continuing ...

    So, sometimes, on my way to doing a task, and as part of it, I encounter some methods/classes that need refactoring, I might take that time to improve some or all of them, while I'm doing the new task, if I can

    so in that way, I'm always coding new stuff, but drying up older stuff as I go along

    kind of like making sure the room isn't too dirty, sometimes it gets dirty and I spend a whole day cleaning it up, but I try to keep it clean as I go and accept that it'll never be tooclean, unless I want to wear rubber gloves and never go outside... then I'd be ocd

    same with code

    hope this sorta helps?
  • 5
    @rant1ng thanks it’s just sometimes my own self forbids to go further unless this is done correctly. Which kinda tearing my own self apart honestly
  • 1
    @devTea depends what your higher goal is

    what do you value most?

    the idea that you have the perfect code,

    (for whatever other emotinal/psychological reasons that sub-processes off to)


    to get the task done for the endgoal of whatever that is, make boss happy, or client, if the latter, what does the client really want


    try to distill and examine your thinking that might cause anxiety/obsession etc and you'll usually find there's some irrationality in there

    try journaling , answer: "why am I obsessed with writing perfect code, why do I use this to beat up on myself, etc"

    I've gotten over so many things like this, just by writing down my thought process, once I write it down, there's usually some really weird shit in there and it's like "ok, next time I think this, i'm not going to think that, instead I'll think this" and then, just practice that until I don't think the weird shit anymore

    sorry if getting personal, just, I can recognize your problem...
  • 1
    When I was totally new to coding the stuff I wrote (or at least tried to write) looked like a necromancers hotpot. Something acid from hell met a virgins blood. It worked somehow, but after I encountered my first programming classes I feel slightly embarrassed looking at my first tries. ^^
  • 1
    Start clean, get messy, clean it, get messy... shit infinite loop irl, how to debug? 😂
  • 1
    Usually, I start clean to get something working at all. At work, I leave it at that state and start documenting. Maintainability is more important than performance.

    With my private stuff, that's where speed profiling starts, and the code gets ugly. Global variables accessed from deep inside the call tree, goto via array index (computed goto), cramming together unrelated variables in bit patterns. Sometimes, I have to read the disassembly to be sure the compiler does what I want. It's as dirty as C can get, but that's the fun part.
  • 1
    I’m trying to do TDD, so it helps to write clean code
  • 1
    Linter with Auto format.

    So can say I write it clean from the start.

    I think we are talking about the appearances of the code rather than logic 🤫

    Ugly hacking duck tape shit is everywhere and I don't think I'll ever clean them in this life 🤫
Add Comment