←back to thread

361 points mmphosis | 1 comments | | HN request time: 0.212s | source
Show context
tegiddrone ◴[] No.42167934[source]
> 5. If a particular function doesn't fit anywhere, create a new module (or class or component) for it and you'll find a home for it later.

I worked at a place that did this with their frontend app. Devs rarely knew where anything should go and so for any given Component/Module, there was usually some accompanying `MyComponent.fns.ts` file. Homes were NEVER found for it later. Code duplication through the nose and lots of spaghetti coupling.

Edit: i'm definitely blowing off some steam. That said, I think there is good virtue in this "habit" so long as there is good reason that it "doesn't fit anywhere" ... and when another module starts referencing the temporary home module, it is a smell that the time is now to give it a proper home.

replies(3): >>42168380 #>>42168425 #>>42170223 #
1. skydhash ◴[] No.42170223[source]
I used to do the utils file, but now it's either a local function (same file, close to usage) or I find a proper home for it (even if it's a rudimentary module).