OSGi可以帮助降低复杂性吗? [英] Can OSGi help reduce complexity?

查看:163
本文介绍了OSGi可以帮助降低复杂性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到很多关于 OSGi 的演示文稿,我认为实施更好的模块化是很有希望的。显然,热门部署和并行运行不同版本的x也是市长卖点。

I saw lots of presentations on OSGi and i think it sounds promising for enforcing better modularization. Apparently "hotdeployment" and "running different versions of x in parallel" are mayor selling points too.

我想知道OSGi承诺解决的是甚么问题吗? ?它提醒了我,当类似的索赔遭殃时,OO的早期时代:

I wonder whether what OSGi promises to solve is even an issue...? It reminded me of the early days of OO when similar claims were maid:

当OO 是新的时候,大的论据是可重用性。广泛宣称,在使用OO时,只需写一次即可随处可见。

When OO was new, the big argument was reusability. It was widely claimed that when using OO, one would only have to "write once" and could then "use everywhere".

在实践中,我只看到这是一个很低级别的例子。我认为这样做的原因是写入可重用的代码很难。不是在技术上,而是从界面设计的角度。您必须预测未来的客户将如何使用您的课程,并采取正确的选择。这是很难定义的,因此潜在的可重用性优势往往无法实现。

In practice I only saw this working for some pretty low level examples. I think the reason for this is that writing reusable code is hard. Not technically but from a interface design point of view. You have to anticipate how future clients will want to use your classes and take the right choices up front. This is difficult by definition and thus the potential reusability benefit often failed to deliver.

使用OSGi ,我怀疑这里再次可以落实承诺,潜在的问题解决方案,我们真的没有。或者如果我们拥有它们,我们就没有足够的数量和严重程度来为OSGi购买帮助。 Hotdeployment例如模块的一个子集绝对是一个好主意,但是它多么真正地工作?多久不会因为事实证明您在特定问题上出现模块化错误?在多个模块之间共享的模型实体如何?这些模块是否必须同时更改?或者您是否将对象平坦化为原语,并仅使用模块间通信中的对象,以便能够保留界面合同?

With OSGi, I have the suspicion that here again we could fall for promises, potential solutions for problems that we don't really have. Or if we have them, we don't have them in a big enough quantity and severity that would justify to buy into OSGi for help. "Hotdeployment" for example of a subset of modules is definitely a great idea, but how often does it really work? How often not because it turned out you got the modularization wrong for the particular issue? How about model entities that are shared between multiple modules? Do these modules all have to be changed at the same time? Or do you flatten your objects to primitives and use only those in inter-module communication, in order to be able to keep interface contracts?

在应用OSGi时,最难的问题是。类似于使用OSGi在OO中获取类的接口,问题保持不变,这个时候更大的规模,包甚至服务级别。

The hardest problem when applying OSGi is, I would presume, to get the modularization "right". Similar to getting the interfaces of your classes right in OO, with OSGi, the problem stays the same, on a bigger scale this time, the package or even service level.

您可能已经猜到了,我正在尝试评估OSGi在项目中的使用。我们所面临的主要问题是随着代码库的增长而增加复杂性,我想在具有较少和更多定义的交互的较小模块中打破系统。

As you might have guessed, I'm currently trying to evaluate OSGi for use in a project. The major problem we have, is increasing complexity as the codebase grows and I would like to break the system up in smaller modules that have less and more defined interactions.


  • 由于没有框架可以帮助决定什么是模块化,OSGi是否已经为您付款?

  • 在团队工作时,让生活更轻松吗?

  • 是否有助于减少错误数量?

  • <你有没有成功地热点部署主要组件?
  • OSGi是否有助于降低复杂性?

  • OSGi是否遵守承诺?

  • 是否满足您的期望?

  • Given no framework can ever help deciding what to modularize, has OSGi ever payed off for you?
  • Has it made your life easier when working in teams?
  • Has it helped to reduce bug count?
  • Do you ever successfully "hotdeploy" major components?
  • Does OSGi help to reduce complexity over time?
  • Did OSGi keep its promises?
  • Did it fulfill your expectations?

谢谢!

推荐答案

OSGi由于在运行时执行模块化而付出代价,这是您以前没有的,通常会导致纸张和实施的设计分散。这在开发过程中可能是一个很大的胜利。

OSGi pays off because it enforces modularization at runtime, something you previously did not have, often causing the design on paper and implementation to drift apart. This can be a big win during development.

如果您让团队专注于单个模块(可能是一组软件包) ),如果您的模块化正确。人们可以认为,可以使用像Ant + Ivy或Maven和依赖关系这样的构建工具来做同样的事情,OSGi使用的依赖关系的粒度在我看来远远超出,而不会导致典型的拖动一切加上厨房水槽 JAR级依赖性导致。

It definitely helps make it easier to work in teams, if you let teams focus on a single module (possibly a set of bundles), and if you get your modularization right. One could argue that one can do the same thing with a build tool like Ant+Ivy or Maven and dependencies, the granularity of dependencies that OSGi uses is in my opinion far superior, not causing the typical "dragging in everything plus the kitchen sink" that JAR level dependencies cause.

具有较少依赖性的模块化代码往往会导致更清洁和更少的代码,从而导致更少的错误,更容易测试和解决。它还促进设计组件尽可能简单直观,同时可以选择插入更复杂的实现,或者添加诸如缓存等方面的单独组件。

Modular code with less dependencies tends to lead to cleaner and less code, in turn leading to less bugs that are easier to test for and solve. It also promotes designing components as simple and straightforward as possible, whilst at the same time having the option to plug in more complicated implementations, or adding aspects such as caching as separate components.

即使在运行时不使用热部署也是一个非常好的测试,以验证您是否正确地模拟了应用程序。如果您根本无法按照随机顺序启动捆绑包,则应调查原因。此外,如果您可以更新任意的软件包,它可以使您的开发周期更快。

Hot deployment, even if you do not use it at runtime, is a very good test to validate if you modularized your application correctly. If you cannot start your bundles in a random order at all, you should investigate why. Also, it can make your development cycle a lot quicker if you can update an arbitrary bundle.

只要您可以管理模块和依赖关系,大型项目就可以管理,可以很容易的演变(拯救你可以说是糟糕的完全重写)。

As long as you can manage your modules and dependencies, big projects stay manageable and can be easily evolved (saving you from the arguably bad "complete rewrite").

OSGi的缺点?这是一个非常低级别的框架,虽然它解决了相关问题,但仍然需要解决问题。特别是如果您来自Java EE环境,您可以获得免费的线程安全性和其他一些可能非常有用的概念,那么您需要自己在OSGi中提供解决方案。

The downside of OSGi? It's a very low-level framework, and whilst it solves the problems it is intended for quite well, there are things that you still need to resolve yourself. Especially if you come from a Java EE environment, where you get free thread-safety and some other concepts that can be quite useful if you need them, you need to come up with solutions for these in OSGi yourself.

一个常见的缺陷是不要在OSGi之上使用抽象,以使平均开发人员更容易。永远不要让他们手动与ServiceListeners或ServiceTrackers混淆。仔细考虑捆绑是不允许做的:您是否愿意让开发人员访问BundleContext,或者通过使用某种形式的声明模型来隐藏所有这些。

A common pitfall is to not use abstractions on top of OSGi to make this easier for the average developer. Never ever let them mess with ServiceListeners or ServiceTrackers manually. Carefully consider what bundles are and are not allowed to do: Are you willing to give developers access to the BundleContext or do you hide all of this from them by using some form of declarative model.

这篇关于OSGi可以帮助降低复杂性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆