Live data from Hacker News

Good refactoring vs. bad refactoring

builder.io

151–154 of 154 posts

Re: Good refactoring vs. bad refactoring

#151
post #34

Words can not express my hate for this kind of articles. Imagine working on a legacy codebase where the PM holds the dogma of refactoring being a bad thing and expecting you to do it wrong, even micro managing your PRs. Most often than not, I do see projects suffering and coders actually resigning due to a lack of internal discussing about best practices, having space/time to test potential solutions, having Lead dev…

> Let me guess, some PM wrote this article

Nah, judging from the ancillaries (domain name, links to other articles, ads, etc) of the article, it was some guy selling an "AI" code tool of some kind who wrote the article.

(Probably a tool with Magikal Refactoring Functionality built-in... For a price.)

Re: Good refactoring vs. bad refactoring

#152
post #117

Ad-post for yet another AI tool. Refactoring is about moving existing code around, not introducing new code. Replacing localStorage methods with cacheManager is a fix/feature. Updating one part of the codebase to work completely differently from the rest is a fix/feature. Changing processUsers to a whole useless class is not considered refactoring, it is a fix/feature. A single page app for a SEO-focused site is NOT…

> Ad-post for yet another AI tool.

Ad-posts for AI tools seem (almost?) always to be written by AI tools.

Only I don't know what proportion of them are written by computerised AI tools.

Re: Good refactoring vs. bad refactoring

#153
post #66
post #16

That OO refactor isn’t actual OO. The tell tale sign is that it is named by what it does rather than what it is (verb vs noun) and the -or ending in the name [0]. It’s just a function masquerading as a class. The better refactor to introduce OO concepts would have been to introduce an isAdult function on the user class and maybe a formatted function. This + the functional refactor probably would have made for the bes…

> u.isAdult() Being adult is not a property of the user but of the jurisdiction that the user is in. In some places or some purposes it is 18 but it could be, e.g., 21 for other purposes. If you software is not going to just run on the USA it is not a good idea to implement isAdult in the user but in a separated entity that contains data about purpose and location.

> Being adult is not a property of the user but of the jurisdiction that the user is in.

It's a function of both. And I'd argue it's really mainly a function of the person: Independently of jurisdiction, there's at least a rough global consensus what "being adult" means, and most jurisdictions set rather similar (many of them, identical) limits.

A four-year-old isn't an adult anywhere; a fourty-year-old is everywhere.

Post reply on HN