TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Settling the File Structure Debate

24 点作者 moebrowne大约 1 个月前

10 条评论

bulatb大约 1 个月前
At the risk of becoming that guy from the tabs vs. spaces meme: Why not both? Name folders by domain or topic and files by role, if you can.<p><pre><code> app&#x2F; iam&#x2F; orgs&#x2F; models.xyz roles&#x2F; models.xyz </code></pre> Then any editor with file search can produce the type-based structure on demand.
GenerocUsername大约 1 个月前
Blog has a unique voice, but also the clear outline structure of a ChatGPT response.
评论 #43873578 未加载
评论 #43873710 未加载
评论 #43873008 未加载
Groxx大约 1 个月前
As much as I greatly prefer context-based grouping when I can get it, I find it breaks down in a few significant ways:<p>Contexts are not always (or even usually?) hierarchical and distinct. This leads to constant variance on if your IAM code belongs in &quot;users&quot;, &quot;auth&quot;, &quot;access&quot;, &quot;api&quot;, or even &quot;iam&quot; (and is that nested under something else or not?). Or maybe it&#x27;s &quot;middleware&quot;? Wait the identity team is called &quot;Galactus&quot;... Every team makes different decisions, and while all may be defensible they&#x27;re still different and can take a lot of time to figure out. Assuming anyone even knows, and it isn&#x27;t just rolling along vaguely on its own inertia.<p>&quot;Directly mirrors stakeholder language&quot; does not always have any bearing on how a thing works or is built. To take the house example, sure, houses have doors and windows. They also have stuff hidden in walls, paperwork that buyers never see, and massive supply chains that nobody actually fully knows - are you modeling those too? They&#x27;re part of a house&#x27;s existence. But obviously you&#x27;re not because you obviously only care about X and not Y... but really, how many times have you run across a business that <i>fully agrees on what X is</i> and is completely consistent on it? Some, surely, but vague sections are often natural because otherwise your market would be a solved problem.<p>And last (OTOH) but not least: business needs and concepts often change with time. Do you restructure your code to match that? At this point you&#x27;re knee deep in the first one above, <i>again</i>, and if you don&#x27;t complete it you&#x27;re left with confusing tech debt.<p>---<p>Type-based layouts benefit greatly from <i>not needing to think about it</i>. Almost everyone is almost immediately able to put things in the right place, and know where to go to find something. Sure, it&#x27;s a bit of a mess in there, but you&#x27;ve still cut out like 75% of the codebase and the task is now smaller.<p>Though obviously ^ this can break down rather badly when the remaining 25% is still much too large to search quickly.
评论 #43873486 未加载
nayuki大约 1 个月前
The article is essentially an instance of the debate about hierarchical folders vs. tags for organizing a collection of files.
12_throw_away大约 1 个月前
TBH I wish we didn&#x27;t have to choose. There are a variety of ways folks might need to read the code, so why not have multiple views of the project, depending on how you want to look at it?
karmakaze大约 1 个月前
It was never a question for me. If you consider visibility by package, domain grouping is clearly the right choice.
Wowfunhappy大约 1 个月前
&gt; If there’s one unshakable prophecy in software development, it’s this: Your code will change.<p>&gt; Maybe tomorrow. Maybe in six months. But change is coming faster than your next caffeine crash from the coffee you had this morning. Smart developers accept this upfront and set up their projects to embrace it, not fight it.<p>...this <i>does</i> depend on the project. If you&#x27;re developing a video game, for example--a single player game like Zelda, not a service game like Fortnite--there actually is a point where your code <i>won&#x27;t</i> change. Similarly, I used to work at an agency that specialized in one-off static websites tied to particular moments in time. While we did sometimes modify these websites post launch, the edits were minor and generally meant something had gone wrong, either on our end or the client&#x27;s.<p>This is kind of unfair to the author. I point this out only because I think it&#x27;s important to acknowledge that some software really <i>is</i> one and done, and it&#x27;s important to know what kind of project you&#x27;re doing. YAGNI and all that.
keeganpoppen大约 1 个月前
this is part of what charmed me about svelte when i first learned about it a while back-- it really does seem like a better way in many ways.
kiitos大约 1 个月前
...for PHP projects
mcbishop大约 1 个月前
tl;dr from the bottom of the blog post:<p>&gt; Type-based grouping is great for tech-focused tasks, consistent naming, and large sweeping changes.<p>&gt; Context&#x2F;process-based grouping shines for domain clarity, team ownership, debugging, and mapping business problems directly to code.