Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

组件化 OR 分层? #5

Open
TotooriaHyperion opened this issue Oct 15, 2020 · 0 comments
Open

组件化 OR 分层? #5

TotooriaHyperion opened this issue Oct 15, 2020 · 0 comments

Comments

@TotooriaHyperion
Copy link
Owner

TotooriaHyperion commented Oct 15, 2020

xufei/blog#50

组件化其实是模块化的一种形式,而设计良好的模块化,其model和view是可以单独复用的,只需要将类型约束在VM层实现的接口即可。而VM层其实也应该可以替换其实现。最终分层都通过接口类型来约束。

MV*是分形的,而前端的组件化,其实是把一个有完整内部逻辑的MV*模块,视作一个view层组件。这本质上只是模块化的一种特例而已。

分层和模块化都是很重要的,但组件化只是它们的一种实现,不足以与它们相比。所以在这个角度,分层当然是优先于组件化的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant