9 ms·
I tell all the junior Devs: if you aren't horrified by something you wrote a year ago, you aren't learning fast enough. 20 years in and I still find things I w
by hinkley 10y ago
I tell all the junior Devs: if you aren't horrified by something you wrote a year ago, you aren't learning fast enough. 20 years in and I still find things I wrote 8 months ago that I would not do again.
- zelos 10y agoI learned that about 4 years ago. I wish someone had told me when I was first starting out as a developer.
- sillysaurus3 10y agoBut it also means that what you're writing right now isn't that bad. If you accept that your best is your best, then your best is good enough. The effort is what matters.
- wingerlang 10y ago> your best is good enough. The effort is what matters. Not necessarily true, if you're (trying to be) a professional then it might not be enough.
- zero_iq 10y agoJudging by some of the 'professional' code I've read over the years, I'd say that's not a particularly high bar...! At least if you're horrified by code you wrote, it shows you care, and that shows some promise :)
- TeMPOraL 10y agoI concur. Especially if you define "professional" as "stuff people do at work, for money", the kind of code I saw in my career... well, it wasn't that much different from the code I was writing when I was 13.
- philbarr 10y agoBest one liner I've ever seen in "professional" code: String myBoolean = "yes"
- sillysaurus3 10y agoI liked enum Boolean { TRUE, FALSE, FILE_NOT_FOUND };
- arethuza 10y agoNot sure I'd say it was he best, but it was certainly memorable: boolean alanIsABastard = true; As I was the only person in the company with that name it was clearly meant for me! :-)
- cjslep 10y agoI was horrified to see: public void encryptCreditCard(int[] cc) { int tmp = cc[0]; cc[0] = cc[6]; cc[6] = tmp; // and so on... } Decrypt version just did the steps in reverse, of course.
- krylon 10y agoA year? Sometimes, a weekend is enough. ;-) Sometimes, of course, you write code that is just right, and it still is after a year. But, yes, that "What-was-I-Thinking" moment happens on a fairly regular basis. ;-)
- fapjacks 10y agoYeah absolutely. I always reduced this to "three months" and passed the phrase around to juniors, etc. And when I interviewed at the last company I worked for, the CEO specifically said, "If you aren't horrified by something you wrote three months ago..." And that's when I knew I wanted to work there (among many other reasons, of course).
- hinkley 10y agoI would worry that this would encourage more tech debt than I'm comfortable with. I already struggle with people shrugging off obviously predictable consequences of their thoughtlessness. I kind of expect people to at least attempt to think three months out. Who knows what we'll be doing in six but cmon.
- fapjacks 10y agoDo you really look at code you wrote three months ago -- or any code you've just written -- and not see a lot of things you could improve? This isn't about not having foresight or failing to plan or not designing well.
- hinkley 10y agoEvery time I am about to do a commit, I look at the code and give myself fifteen minutes to make it better. Always have (probably a habit I learned doing homework in college? I'm not quite sure). In the grand scheme of things you'd hardly notice that it takes me a little bit longer. Over time those improvements become habituated and I just do a lot of them while I'm coding. Especially when I get stuck. It's not in like cleaning while you cook. Once you have a tempo it hardly takes any longer to prepare the food but you don't leave yourself with a mess that discourages you from doing it again.
- laumars 10y agoMy favourite is when I go back to old code, think "why on earth was that written that way" and then proceed to rewrite it. Then after an half an hour in I realise that my rewrite is worse than the original method I used. At which point I promptly undo my changes then leave a comment for future self explaining why my superficially bad code works well. Sadly those instances are fewer than those where my old bad code is literally just bad.
- simpleProMan123 10y agoI don't mean this as a response to you personally, but instead to everyone who works this way. We've been in this situation lots of times, where we'll write some code, then finish the solution after a few days or a week, then look at it a month later and say "Wow, this is really not a good way of doing it," only to spend another few days or weeks rewriting it. The idea of spending 10 minutes drafting a solution, throwing it out, spending another 10 minutes on diagrams and guesses, throwing it out, typically gets met with "Just _code_ damnit," but, diagramming could compress months of rework into minutes.
- laumars 10y agoYou're not wrong and my programming style is very much like that albeit I use the code itself to diagram as I find that's easier for my brain to parse than flow charts. But effectively it's the same process of "sketching a design and throwing it out" cycle that you described. I suspect quite a few developers who "just code damnit" follow this same process too. After all, it's not exactly hard to rewrite code and with tools like Git in place you can easily stash the different implementation methods so you're not having to lose any work during the cycles. Usually when bad code gets written by experienced developers it's not so much because of a lack of willingness to conceptualise the design but often just because either the deadline is sufficiently tight that you are forced into writing a "quick fix" rather than something robust. Or because the code base is already an mess (due to the evolution of the product and the aforementioned issue of quick fixes) which means the "ideal world" solution is a significantly larger undertaking than it should be and best not undertaken while you have deadlines depending on it. Or sometimes you see "bad" code simply because the aim of the project is a minimum viable product or proof of concept, thus it's more about proving the product works as a concept than the implementation of it. In that scenario it can make a lot of sense to throw quick code at a problem with the understanding that chunks of the application will be revisited when you start to scale the product.
- tomgp 10y agoI regularly ask interviewees at all levels, after they've talked me through some code they've written, how they would do it differently (emphasising that I always wish I'd done things differently). It's one of the questions I've found to be consistently helpful in finding out how a person thinks about making software 1. it's a good indication about how they think about improving existing code 2. it can show how they learn from what they do 3. it give them license to talk openly about mistakes (much better than a rote 'tell me about something that hasn't gone well' type question)
- hinkley 10y agoI once had a guy answer 'nothing' to that question. I ended the interview as quickly as I could after that.
- Klockan3 10y agoI disagree, if you consistently think that the code you wrote a year ago is shit then you are probably just chasing a new fad every year. I'd say that if a junior developer with a year in a language doesn't write code he can rightfully be proud of then he is focusing on the wrong things.
- braveo 10y agothank you, I say the same thing every time I see this come up. That's a young mans game, after you've been doing this stuff long enough the things you learn are in terms of systems design, maintenance, etc. I regularly go back to code I wrote 2 and 3 years ago and think to myself "knowing what I know now, that code is mostly alright". I can't understand how someone can go back and look at some authentication code, for example, and think the way they did it was horrible. Just how many different ways can you write auth code? It's one thing if you're a young developer, but at some point the improvements to your code are negligible and have nothing to do with the value you bring to a project.
- Fifer82 10y agoWhere do you guys get a job without any time constraints? Also were you born with all knowledge? You are saying for example that the booking system you made in 2009, which was the first time you ever "programmed time" is pretty much perfect? (change the example to shaders, or physics, or your first Node back end blah blah). I am calling Bullshit.
- braveo 10y agoI would think the ones who constantly go back and worry about old code are the ones you would accuse of having no time constraints. The thing is, if you're going back to the first time you've ever "programmed time", then what you're assessing is design, not code, which falls in line with what I said.
- tomgp 10y agoYes, the scale at which you notice problems with older code changes as you gain experience. i.e. you may have it down at a function or class level but then, at a system design level, or perhaps in the way that the code addresses business needs there will likely be improvements that you can see given the benefit of hindsight and experience. [edited to remove typo]
- psyc 10y agoMy father was a fairly well-known concert pianist in his day, who also taught students continually. Each week, he would be enthralled with a new practice technique or hand exercise he had arrived at. Last week's technique was abandoned, not mentioned again. My mother would mock this, implying that he must not know what he was doing, since he changed his mind so often about what works. He explained to me that the exercises were not being abandoned at all. They were being refined gradually over time. He had one goal, which was improving the uptake and resilience of brain and muscle memory for music. Every refinement was an opportunity he'd spotted, deep in his own mental language, to hone in on that goal. The way my coding style (both deep and superficial) changes continuously over time always reminds me of the way my father taught piano. My goal, roughly, is to find the perfect balance of clarity and brevity, while maximizing the ease of continued development. My 27 years of practice has resulted in a long chain of insights about how to achieve that. It's always changing. The way I wrote code 8 months ago wasn't wrong, but I found a set of principles that's better. It wasn't bad, but I would not write in that style today. Why would I? I've learned things in those 8 months.
- taneq 10y agoOr maybe they just had a decent feel for design already? I look back at some things I wrote in the first couple of years that I was coding, and it's actually pretty alright. Maybe a bit amateurish and not how I'd do it now, but not terrible. I can't be the only one like this.
- jscholes 10y ago> Maybe a bit amateurish and not how I'd do it now, but not terrible. I can't be the only one like this. Not at all. I started my first real project in September 2015, had a release out by mid-November. And the code worked, really well. I was praised by users of the software for how reliable it seemed to be. Now, 15-16 months later, I can definitely see the warts - there's a lot of global state, some crackpot abstractions and if I ever want to add new features to it I'll have to do some spring cleaning. But at the same time... it still works. The design is appropriate enough for the needs of the project and its functionality.
- vkjv 10y agoOne of my favorite quotes, "the dev whose code I hate the most is me from 2-years ago." One of the unfortunate outcomes of the job market encouraging job hopping for salary bumps is many new engineers don't get the opportunity to see the cost of their own mistakes.
- hinkley 10y agoThe wise man learns from the mistakes of others.
- juba08 10y agogood point. i am a perfectionist but if there is any deadline in a project i make too much mistakes and i mostly realize i wrote bad code a month ago.
- dep_b 10y agoThe difference between a junior dev and a senior dev is that you already know it's ugly code and it's going to bite you some time in the future when you write it.
- thrillgore 10y agoI'm currently working on a project that has mistakes as early as Monday I want to go back and rewrite.
- Shorel 10y agoI don't think what you describe has happened to me. I can be horrified by something I'm writing right now, and if I check that code much later, remain horrified and add ashamed to the list. But if I write code that I feel is good, then after ten years it is still clear code, concise and easy to understand, therefore, still good. May be I am not learning fast enough. But everyone can easily understand my code.
- bmpafa 10y agoI'm embarrassed of code I wrote as recently as this morning -- I must be some kinda gifted.