Live data from Hacker News

Ask HN: Does every software project require a refactor?

news.ycombinator.com

11–13 of 13 posts

Re: Ask HN: Does every software project require a refactor?

#11
post #6

Require? No. Could use one? Yes. Every project could use refactoring, at all stages.

“Premature optimization is the root of all evil” https://effectiviology.com/premature-optimization/ IOW, don't waste time in refactoring if it is not imperative for some particular reason.

This is greatly mistaken. Continuous refactoring is imperative. Not doing it is like owning a house and never doing basic maintenance. Refactoring is orthogonal to optimization.

Re: Ask HN: Does every software project require a refactor?

#12
The words software project are doing a lot of work in this sentence.

Refactoring is a function of scope and scope violations. When things violate their scope and use global state, the end result is brittle hard to change and even harder to test code.

Many scopes will need to be refactored over time and if elements of a software project are tightly coupled that will mean refactoring the project rather than a module or a component.

As the sins of short term thinking accumulate so too does the daily pain of working on a project until people start to want to factor out their components (in the worst case this is called micro-services), or do a complete re-write.

I think refactoring should always be done with any change to fix scoping problems (removing usage of global state) and a complete refactor is to be reserved for core architecture problems and scaling issues.

The most sane approach is to use something like bazel to start limiting what can depend on what where, which will slowly start to decouple components, likely via forcing dependency injection.

Once you have pressure pushing in the direction of lower complexity (via enforcing limitations) rather than increasing complexity, a lot of problems that seem untenable before become approachable.

Re: Ask HN: Does every software project require a refactor?

#13

Earlier quoted context omitted.

“Premature optimization is the root of all evil” https://effectiviology.com/premature-optimization/ IOW, don't waste time in refactoring if it is not imperative for some particular reason.

This is greatly mistaken. Continuous refactoring is imperative. Not doing it is like owning a house and never doing basic maintenance. Refactoring is orthogonal to optimization.

As a general rule, and operus memorandi, I agree 100%.

But like any rule, if we're talking specifics, there are exceptions. Scripts you use occasionally do not need developer time committed to iterating on. They can technically be improved, and refactoring them would likely lead to benefits, but they don't require it. There is nuance.

Post reply on HN