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

精读《插件化思维》 #75

Closed
ascoders opened this issue Apr 12, 2018 · 15 comments
Closed

精读《插件化思维》 #75

ascoders opened this issue Apr 12, 2018 · 15 comments

Comments

@ascoders
Copy link
Owner

插件化思维可以用来做技术工具,前端框架,或者做项目,一个合格的技术规划者应当拥有插件化思维。

可惜这方面文章比较少,除了零星的设计模式启发之外,很少能看到介绍如何做插件化的文章。笔者在经历许多项目的洗礼后,尝试总结一下,帮助大家养成插件化思维。

@ascoders ascoders mentioned this issue Apr 12, 2018
65 tasks
@atian25
Copy link

atian25 commented Apr 12, 2018

文章地址?

@ascoders
Copy link
Owner Author

@atian25 哎,找不到文章啊,就是想写这个主题的,有没有推荐文章?

我准备从做过的项目,以及看过的框架,cli 工具设计理念入手来分析。有文章指导就更好啦!

@atian25
Copy link

atian25 commented Apr 12, 2018

也没有,不过这块倒是接触不少。

FIS,Egg 都是强插件化理念的。

@ascoders
Copy link
Owner Author

这俩我都是忠实用户,哈哈。

有点慌,因为这个文章是写给做架构的同学看的,写完后如有理解不足之处希望批评指正,我这次先献丑了!

@atian25
Copy link

atian25 commented Apr 12, 2018

洗耳恭听~

@huxiaoyun
Copy link
Contributor

抛个砖:
感觉插件化思想很老了,系统为了保证扩展性,给第三方提供更大的自由度,提供插件化的机制。对于系统来说重要的是提供一个标准,能够让插件统一接入,并让系统调用方使用。

相对于java 系统可以提供统一的接口,让第三方按照规定实现指定的方法,前端似乎就比较开放。有些像jquery 的插件,只需要开发者往 $.fn 上挂载一个方法,输入参数、设计都随意开发者发挥了。像webpack 的插件,就规定了 apply 方法的入口,往钩子上写自己的逻辑代码。

ps: 还真没怎么找到插件架构方面的文章。。。
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingCode/Concepts/Plugins.html#//apple_ref/doc/uid/20001272-98794-CJBEAEAD

@ascoders
Copy link
Owner Author

@huxiaoyun 说的更像 interface(接口)的定义,做技术项目需要的插件化思维是更上层的概念,要考虑的点也更多。

比如如何加载插件?如何定义插件语法?支持一套还是几套插件?核心也用插件写吗,要注意拿捏到何种分寸?哪些项目可以用插件机制做,带来的好坏处如何权衡,等等。

@ascoders
Copy link
Owner Author

上面先抛个砖,如果能吸引一些讨论,文章也会更好写一些。

@ghost
Copy link

ghost commented Apr 16, 2018

image

@linonetwo
Copy link

我之前整理了一些可以参考的文章 http://onetwo.ren/%E5%89%8D%E7%AB%AF%E6%8F%92%E4%BB%B6%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1/#%E5%8F%82%E8%80%83
之前想做一个支持插件的笔记系统来着,不过坑了,所以我写的那篇文章也太监了。

@usernamedd
Copy link

我是想看桌面程序的插件化思想的,结果这里的是更灵活的前端的东西,但是思想有相同的地方,系统留一些切口供插件插入。想深入插件化开发模式,可以参考Visual studio , visual studio code ,ellicpse,但是都是桌面程序的例子。
最后,闲着没事把这个issue关了弄啥

@linonetwo
Copy link

@usernamedd 现在很多桌面程序就是用 electron 开发的,我最近在开发跨平台战棋游戏,用的就是 electron + react + pixi

@usernamedd
Copy link

@usernamedd 现在很多桌面程序就是用 electron 开发的,我最近在开发跨平台战棋游戏,用的就是 electron + react + pixi

嗯,不错,有开源地址吗,欣赏学习一下

@linonetwo
Copy link

@usernamedd 游戏是 https://github.com/linonetwo/Eternity-Foundation 还刚开始开发

mod 系统是 https://github.com/linonetwo/Eternity-Foundation/blob/634ccd4e31784c855f6d8f3e1036bf070a196b6d/src/redux/models/mod.ts#L5 ,其实是把一些 API 暴露给 new Function ,载入用户脚本,利用 electron 的 contextIsolation 沙盒保证 mod 代码没法作恶。

@Pines-Cheng
Copy link

Pines-Cheng commented Nov 3, 2020

推荐 VSCode/Theia 源码里面的 Extension/Plugin 设计,基于强大的、轻量级的 IoC 容器 InversifyJS,高级优雅而又功能强大。整个 IDE 都是 Extension 组成的,对外提供 Plugin 机制进行拓展。

参考:Authoring Theia Extensions 以及 Authoring Theia Plug-ins

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

6 participants