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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Fragmentation

19 点作者 r4um超过 1 年前

4 条评论

jongjong超过 1 年前
&gt; If the problem was decomposed based on ‘natural’ lines that tend away from dependencies, then the idea of treating stuff as fragments would work. But they don’t know what that means, so it doesn’t happen.<p>This is such a good line. Most dependencies I see in enterprise software fail miserably at this and that&#x27;s why they think they need a monorepo.<p>I&#x27;ve found that people with substantial open source experience are often much better at figuring out what the &#x27;natural&#x27; lines are because they tend to see the modules and libraries which they produce as final products. Their libraries are designed to be highly composable and cater to a broad range of use cases and systems.<p>The key is writing components that are generic and broadly compatible. You want to avoid putting business logic into your dependencies. Try to keep all the business logic at the highest level possible in your code.<p>It&#x27;s very simple if you think about it; just imagine that you&#x27;re a new developer on a large project, what would you want the code to look like? Most likely, you want to be able to understand what the system is doing by reading as few files as possible and you want the system&#x27;s features to map to these top-level files in an obvious way.<p>Because when you&#x27;re debugging a feature, the first thing you need to do is figure out where in the code that feature is implemented. If you can&#x27;t come up with a simple answer to this, then your system is probably poorly implemented.
评论 #38660114 未加载
Jean-Papoulos超过 1 年前
As with anything, it&#x27;s in the middle ground that the best solution is often found. I&#x27;m working on a piece of software that&#x27;s so unfragmented that one of the exe it produces, which by all accounts ought to be around 10MB, ends up being 110MB. Because it&#x27;s not possible to detangle the mess.<p>At the same time, too much fragmentation will lead you to, indeed, have so many callbacks and other &quot;controller&quot; classes that you&#x27;ll need a non-trivial amount refactoring anything you need to add a new feature, because the previously chosen lines of delimitation don&#x27;t correspond to what the new feature needs.
inamberclad超过 1 年前
Encapsulation vs decomposition is a recursive problem. It can happen at any complexity scale. The trick, I think, is to find the level between the two that works for your project. Can you decompose your project into small, independent, testable units? Can a single unit be tested in isolation from all the others? One person will tell you that&#x27;s a fragmented system while another person will tell you that all your software components are nicely encapsulated. It depends on your perspective and your needs.<p>P.S. in any case, a robust interface specification is a prerequisite to good engineering.
cloogshicer超过 1 年前
I don&#x27;t think encapsulation is the answer either. It leads to the same problems that the author mentions (which I think are real).<p>Brian Will has a very good video explaining this (timestamp is where he talks about encapsulation).<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;QM1iUe6IofM?t=1090" rel="nofollow noreferrer">https:&#x2F;&#x2F;youtu.be&#x2F;QM1iUe6IofM?t=1090</a>