News for hackers. Stuff that matters.
Re:Ask HN: How to be productive with big existing code base by emilsedgh on Wednesday February 27, 2019 @08:47PM (#19268402)
This is quite true.

But it must be noted that the code may actually be bad. Or it may be bad due to a thousand valid reasons (time pressure, business changes, etc)

My personal approach is this:

* Write new code must be "good" (Whatever that definition is)

* As you iterate through old code, clean them up.

For example our own codebase is several years old Nodejs project. Mostly written in callback style with `async.auto` and it's really ugly and hard to maintain comparing to async/await.

All our new code uses promises and async/await. All old codebase uses callbacks. We have to use promisify a lot.

But without any hiccups, we are slowly and slowly moving towards a better codebase.

What helps "immensely" is tests. We have 2 different layers of test and I don't think anything would've been possible without them (although none of them are at 100% coverage. Nowhere near)

Re:Ask HN: How to be productive with big existing code base by bradleyjg on Wednesday February 27, 2019 @09:36PM (#19268594)
I go back and forth if the code I'm adding should be what I consider good or if it's more important that it match the flow and feel of what's already there. A code base written in twelve different ways is usually even harder to read and understand than one that's "not good".
Re:Ask HN: How to be productive with big existing code base by vonseel on Thursday February 28, 2019 @12:05AM (#19269069)
Well definitely don’t write bad code intentionally!
Re:Ask HN: How to be productive with big existing code base by teddyh on Thursday February 28, 2019 @01:42AM (#19269470)
Certainly, but the definition of “good” changes over time. At one point, callbacks were good, and now they’re not. What happens when the definition of “good” changes a second time before the code base has been fully converted from callbacks? Well, you shouldn’t write bad code, so now the code has three code styles in it, and, more importantly, two styles of conversions: From callbacks to current-good style and from previous-good style to current good style. This is harder to keep in your head, so conversion now goes more slowly.
Re:Ask HN: How to be productive with big existing code base by tcgv on Thursday February 28, 2019 @02:22PM (#19274230)
I share the same perspective. The value of a code base following one single coding style/convention/architecture is huge, even if there's a better coding approach right around the corner.
Re:Ask HN: How to be productive with big existing code base by arvinsim on Wednesday February 27, 2019 @08:51PM (#19268420)
Yes. Trying to refactor everything at one go is a disaster waiting to happen. It is always best to do it incrementally.