4 ms·
Things You Should Never Do https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/ https://www.joelonsoftware.com/2000/04/06/things-you-sh
by SoftTalker 3y ago
Things You Should Never Do
https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/ https://www.joelonsoftware.com/2000/04/06/things-you-should-...
An oldie but a goodie
- IgorPartola 3y agoI think this is a great article that takes a maximalist point and that’s its flaw. You should rewrite code only when the cost of adding a new feature (one that is actually necessary) to the old codebase becomes comparable to designing your entire system from scratch to allow for that feature to be added easily. That is to say that the cost of the rewrite should become comparable to the cost of continuing development. I have been a part of a couple of rewrites like that, one of them quite complex, and yes they were warranted and yes they worked. But having said that you should absolutely be conservative with rewriting code. It’s a bad habit to always jump to a rewrite.
- devjab 3y agoI think it’s very dependent on how you use words like “rewrite” or “refactor”. The point the author makes about the two page function, and all the bug-fixes (lessons learned) makes sense only if you “rewrite” from scratch without looking at the history. You can absolutely “rewrite” the function in a manner that is “refactoring”, but will often get called “rewrite” in the real world. This may be because “refactor” is sort of this English CS term that doesn’t have a real translation or usage in many languages and “rewrite” is sort of universal for changing text, but in CS is sort of “rebuilding” things. I don’t think you necessarily need to be conservative about rewriting things. We do it all the time in fact. We build something to get it out there and see the usage, and then we build it better and then we do it again. Which often involves a lot of “rewriting” but thanks to principles like SOLID’s single responsibility makes this rather easy to both do and maintain (we write a lot of semi-functional code and try to avoid using OOP unless necessary, so we don’t really use all the parts of SOLID religiously). I do agree that it’s never a good idea to get into things with the mind-set of “we can do this better if we start from scratch” because you can’t.
- giraffe_lady 3y agoThere's currently a trend towards shitting on microservices-everything, imo largely justified. But missing from that is that identifying a logical feature and moving it to a microservice is one of the safer ways to begin a gradual rewrite of a critical system. And usually possible to get cross-dept buyin for various not always wholesome reasons. It may not always be the best technical solution but it's often the best political one when a rewrite is necessary.
- carlmr 3y ago>identifying a logical feature and moving it to a microservice is one of the safer ways to begin a gradual rewrite of a critical system Why not identify that same logical feature and move it into a library. How does a Microservice add value here? Identifying, extracting and adding tests to logical features has been the sane way to rewrite software for ages. Michael feathers even wrote a book about it [1]. This ship of theseus approach works because it's incremental and allows for a complete rewrite without ever having non-functional software in between. Adding a REST/networking/orchestration boundary to make it a Microservice just for the sake of extracting it adds a lot of complexity for no gain. Microservice can be the right architecture, but not if all you want is to extract a library. [1] https://understandlegacycode.com/blog/key-points-of-working-effectively-with-legacy-code/ https://understandlegacycode.com/blog/key-points-of-working-...
- pphysch 3y agoThe issue here isn't "rewriting" per se but "stopping development". You shouldn't stop development on your important products. Letting a couple of your talented programmers loose on a greenfield reimplementation is a perfectly sane strategic move. Stopping development on important products because you are 100% certain that the reimplementation will be successful by $DEADLINE is a foolish gamble.
- paulddraper 3y agoThe problem is if it snowballs
- pphysch 3y agoAny project, whether it's a "rewrite" or not, can succumb to scope creep and poor project management.
- devjab 3y agoIsn’t that how you end up with Python 2 and 3 though?
- wiz21c 3y agoPython3 changes were many "little" things; some more fundamental than other (unicode str). So I guess they were able to split the work in tiny pieces and, ultimately, were able to manage the project...
- pphysch 3y agoYes, that was a rough migration process, but the long-term result is we have an improved language and growing community instead of Python going the way of PHP and Perl. Between the 3 P's, Python's strategic decisions in 2000s were clearly the most successful. And it wasn't a total rewrite.
- hurril 3y agoThe big problem there is that the people you are letting loose on the alternative, are lost from the original, so O loses steam that A gains. You still have to produce bug fixes and features to _both_ O and A to keep them in sync. So you essentially have a doubled required production rate to be delivered using the same staff. So in order for there to be a net gain, the gang working on the alternative have to be able to find such big wins as to being neigh impossible. This is a very very hard problem in our domain. 99% of the time, we have to simply resist the urge to _just rewrite the sucker_. No! Don't do it! (And this is incredibly hard because we all want to.)
- h0l0cube 3y ago> Well, yes. They did. They did it by making the single worst strategic mistake that any software company can make: > They decided to rewrite the code from scratch. Absolutely not what's being proposed for Postgres.
- yxre 3y agoProcess isolation affects so many things in C. The strategy change is going to require changes to so many modules that it will either be a re-write or buggy. In practical terms, if every line needs to be audited and updated, it is a re-write
- anarazel 3y agoWhat makes you think that it will require that many changes? There will be some widespread mechanical changes (which can be verified to be complete with a bit of low level work, like a script using objdump/nm to look for non-TLS mutable variables) and some areas changing more heavily (e.g. connection establishment, crash detection, signal handling, minor details of the locking code). But large portions of the code won't need to change. Note that we/postgres already shares a lot of state across processes.
- giraffe_lady 3y agoI'm not the person you asked and I don't have any particular knowledge of postgres internals. Experience with other systems has taught me that in a system that's been in active use and development for decades, entanglement will be deep, subtle, and pervasive. If this isn't true of postgres then it's an absolute freak anomaly of a codebase. It is that in other ways, so it's possible. But the article mentions there being thousands of global variables. And Tom Lane himself says he considers it untenable for exactly this reason. That's a very good reason to think that it will require that many changes imo.
- h0l0cube 3y ago> that many changes The 'that many changes' in question is a complete rewrite. Many changes across many files, yes, but nothing even approaching a rewrite. > I don't have any particular knowledge of postgres Judging by their bio, the person you're replying to does.
- bandrami 3y agoThe lesson that "cruft is problems someone solved before you" is unfortunately entirely lost on most devs today
- HeavyStorm 3y agoLove this article. Completely changed the way I think about certain projects.