构建可在应用程序之间共享的扩展 Cairngorm 类的最佳方法是什么?

发布于 2024-07-23 05:12:41 字数 568 浏览 7 评论 0原文

我创建了一些事件和命令类以在我的 Cairngorm 项目中使用。

例如,我创建了一个扩展com.adobe.cairngorm.control.CairngormEvent的类,它允许我在相应命令完成或失败时设置回调函数。 为了实现这一点,我还必须创建一个新的类来实现我为项目中的所有命令扩展的com.adobe.cairngorm.commands.ICommand

现在,我想在我的所有 Cairngorm 应用程序中使用这两个类。 做这个的最好方式是什么? 我是否应该编辑 CairngormEventICommand 的 Cairngorm 源代码并重新编译 Cairngorm MVC(这可能吗)? 或者将我的两个类添加到 Cairngorm 源代码中并重新编译 Cairngorm MVC? 或者我应该将它们添加到共享库中?

我现在选择了第三个选项,但这要求我在我的库和每个项目中引用 Cairngorm 库。 我想知道是否有更好的做法以及有什么好处。

谢谢。

I have created a few Event and Command classes for use in my Cairngorm projects.

For example, I created an class that extends com.adobe.cairngorm.control.CairngormEvent that allows me to set callback functions upon completion or failure of the corresponding Command. To accomplish this, I also had to create a new Class that implements com.adobe.cairngorm.commands.ICommand that I extend for all Commands in my projects.

Now, I want to use these two classes across all of my Cairngorm applications. What is the best way to do this? Should I just edit the Cairngorm source for CairngormEvent and ICommandand recompile the Cairngorm MVC (is that even possible)? Or add my two classes to the Cairngorm source and recompile the Cairngorm MVC? Or should I just add them to a shared library?

I've chose the third option for now, but this requires that I reference the Cairngorm library in both my library and each project. I am wondering if there is a better practice and what the benefits are.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放赐 2024-07-30 05:12:41

您提出的所有选项都将起作用。 不过,我建议保留 Cairngorm 源代码和 SWC,只用您的类创建一个单独的 SWC。 您不想在 Cairngorm 源代码每次发布新版本时都对其进行修补。

您有 2 个选项用于编译自定义 SWC(在引用库的构建路径选项中):

  1. 外部引用 Cairngorm 库:然后您需要链接 Cairngorm SWC 和您的自定义 SWC 到您的项目中。

  2. 合并 Cairngorm 库到您的 SWC 中:如果您确保所有 Cairngorm 类也都编译到其中,则只需引用您的库。 只有您引用的 Cairngorm 类(例如通过扩展它们)才会合并到您的自定义 SWC 中。 您可以通过在代码中的某处引用其他 Cairngorm 类来强制包含它们。

我个人更喜欢选项 1,因为这是分离代码库的最干净的方式,它允许您交换/升级 Cairngorm 的版本,而无需重新编译您的库。

All the options you propose will work. However I would suggest to leave the Cairngorm sources and SWC as is and just create a separate SWC with your classes. You don't want to patch the Cairngorm sources each time they release a new version.

You have 2 options for compiling your custom SWC (in the build path options of the referenced libraries):

  1. Externally reference the Cairngorm lib: you'll then need to link both the Cairngorm SWC and your custom SWC into your projects.

  2. Merge the Cairngorm lib into your SWC: you'll only need to reference your lib if you make sure all Cairngorm classes are also compiled into it. Only the Cairngorm classes that you reference (by extending them for instance) will be merged into your custom SWC. You can force an include of the other Cairngorm classes by referencing them somewhere in your code.

I personally prefer option 1 since this is the cleanest way of separating code libraries and it allows you to swap/upgrade versions of Cairngorm without having to recompile your library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文