October 3, 2017 at 9:04 pm
Comments posted to this topic are about the item Rewrite Your Code Tomorrow
October 4, 2017 at 1:29 am
Another great article Steve, thanks.
We re-write a lot of stuff here. Time is the only critical/limiting factor. The benefits are clearer code that's more understandable, easier to change and maintain. Just taking the time to re-format and annotate code has benefits regardless of whether bugs are fixed or performance improved. Often when you re-format and annotate your code the issues or improvements that could be made become searingly obvious.
October 4, 2017 at 3:04 am
Any short period of time between writing and reviewing will improve your code. I discuss this all the time with our devs and do my best to cajole them to revisit and tidy the structure up to little avail. No-one ever wants to look at code they have written that works while they still understand it sadly 🙁
That said I think code standards have improved considerably overall in the last 5 years here so it's not all bad.
October 4, 2017 at 4:43 am
I would dearly like to revisit some code that works but could be better written and/or made more efficient. At the moment I am having to modify a program to add in something that was not in the original requirements. The structure is all wrong for the new feature but I do not have the time redo this and have said I feel like I am adding an illegal extension to a house! 🙁
One of my big frustrations is maintaining somebody else's old code which was probably not reviewed, and because it worked lacks any sensible commenting!
October 4, 2017 at 6:01 am
There's many projects I'd love to rewrite, but there's no time unless the rewrite fulfills a business goal. Just like programming languages, good-enough beats better...
October 4, 2017 at 6:39 am
mjh 45389 - Wednesday, October 4, 2017 4:43 AMI would dearly like to revisit some code that works but could be better written and/or made more efficient. At the moment I am having to modify a program to add in something that was not in the original requirements. The structure is all wrong for the new feature but I do not have the time redo this and have said I feel like I am adding an illegal extension to a house! 🙁
I have the same feeling. I have a project that I completed a few years ago that I would love to overhaul. I was learning a new development methodology as I developed the project and you can tell when you look at the code. The sections that I wrote towards the end of the project are significantly better than those I wrote at the beginning.
I also really like your analogy. I may have to borrow that one. 😀
October 4, 2017 at 7:57 am
Good comments, and thanks. Note, I'm not looking to rewrite an entire project or a huge section. Just rewrite the code (or some of it) from yesterday.
October 4, 2017 at 8:22 am
Even the best developers can write bad code when they're under the influence of adrenaline, sleep deprivation, and poor requirements. Just like professional authors have editors, it helps to have another developer (perhaps a specialist) who can review your code and tidy it up in terms of sanity checking, performance optimization, and commenting.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
October 4, 2017 at 8:36 am
chrisn-585491 - Wednesday, October 4, 2017 6:01 AMThere's many projects I'd love to rewrite, but there's no time unless the rewrite fulfills a business goal. Just like programming languages, good-enough beats better...
Unfortunately, this sometimes is very true. There's been several projects I wanted to improve and ordered not to. It really is "good enough beats better".
Kindest Regards, Rod Connect with me on LinkedIn.
October 4, 2017 at 8:42 am
Great article, Steve. More often than I care to say, I've come across old code and asked myself what cretin wrote this crap, only to discover that it was me.
This article reminds me of one of the test programming websites (I think its CodeKata) that actually encourages you to come to their website, take one of the short problems, solve it. Then a week or so later go back and solve the same problem again, but in a different way. It really is worth your time.
Kindest Regards, Rod Connect with me on LinkedIn.
October 4, 2017 at 8:52 am
One other good way to practice is exercism.io
October 4, 2017 at 2:42 pm
I've had instances (if rarely) where I've been forced to re-write something (because it got lost, over-written, or whatever) and I've always been able to re-create it more quickly and cleanly the second time. Usually, this seems to be because the first time, you had to struggle through the nitty-gritty details of the logic, whereas the second time, it seems like the big picture became clearer, and certain elements could be cleaned-up, tweaked, or even eliminated.
Brian Bartsch
October 4, 2017 at 3:12 pm
This topic reminded me of some writers and artists who (inadvertently or deliberately) destroy the first versions of their work, but then go on to produce a subsequent version for which they become famous. For example:
The story of Dr Jekyll, Mr Hyde and Fanny, the angry wife who burned the first draft
https://www.theguardian.com/uk/2000/oct/25/books.booksnews
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
October 5, 2017 at 7:31 am
I ve been fortunate enough to have redesigned sections of some of my systems periodically over the years mainly because the systems have been successful and the remit has expanded or because I simply have learnt or been told about a better way of doing something. There are some technical debt parts that start to annoy me as well and I end up working on them outside of work as they just are seriously bugging me. I found it a good exercise with VBA to have some practical examples of loops and recordsets and try and write them semi rote over and over and see if I can't do them really quick.
I try and generalise some of my code and write it to a diary as well - I find that useful for reviewing and really getting to grip with certain aspects of my code. I did think about trying to write my own application to hold this but wordpress really seems to be far better than anything I could probably put together.
cloudydatablog.net
October 5, 2017 at 8:05 am
I think this might apply more to POC type work, and I'll usually go through several iterations of a new idea before running with a final version. However for some things it's so straight forward or I have a basic template for what I'm doing and there would be no reason to rewrite it. I tend to think of it more from the perspective of a skilled craftsman, not everything has to be a beautiful unique work of art, sometimes doing things precisely and correctly on the first try is also rewards 😀
Viewing 15 posts - 1 through 15 (of 19 total)
You must be logged in to reply to this topic. Login to reply