【24h】

Measuring Inappropriate Generosity with Access Modifiers in Java Systems

机译:在Java Systems中测量不恰当的慷慨,可以使用Java系统中的访问修饰符

获取原文

摘要

Every element of a software architecture, e.g. a subsystem, package, or class, should have a well-defined interface that exposes or hides its sub elements according to the principles of information hiding and encapsulation. Similar to other object-oriented programming languages, Java supports defining interfaces on several levels. The accessibility of types, methods, and fields can be restricted by using access modifiers. With these modifiers, developers are able to define interfaces of packages and classes tailored for different groups of clients. However, in programming practice, types and members seem to be often declared with too generous access modifiers, i.e. they are accessible by more clients than necessary. This can lead to unwanted dependencies and software quality degradation. We developed an approach to measuring the usage of access modifiers for types and methods in Java by defining two new software metrics: Inappropriate Generosity with Accessibility of Types (IGAT) and Inappropriate Generosity with Accessibility of Methods (IGAM). Furthermore, we created a tool called Access Analysis that calculates and displays these metrics. Using Access Analysis, we conducted a survey on twelve open source Java projects. The results support our assumption that access modifiers are often chosen more generously than necessary. On average, around one third of all type and method access modifiers fall into this category. Especially top-level types are almost always declared as public, so that package interfaces typically expose more types than necessary. Only 2% of all investigated top-level types are encapsulated inside their package.
机译:软件架构的每个元素,例如子系统,包或类应具有明确定义的接口,该接口根据信息隐藏和封装的原则公开或隐藏其子元素。类似于其他面向对象的编程语言,Java支持在多个级别定义接口。可以使用Access Modifiers来限制类型,方法和字段的可访问性。使用这些修饰符,开发人员能够为不同的客户组定制为量身定制的包和类的接口。但是,在编程实践中,类型和成员似乎经常被宣称使用过于慷慨的访问修饰符,即,它们可以由更多客户端访问,而不是必要的。这可能导致不必要的依赖关系和软件质量劣化。我们开发了一种方法来测量Java中类型和方法的访问修饰符的方法,通过定义两个新的软件指标:不适当的慷慨,具有类型的可访问性(IGAT)和不适当的方法(IGAM)的可用性。此外,我们创建了一个名为Access分析的工具,可以计算和显示这些度量标准。使用访问分析,我们对十二个开源Java项目进行了调查。结果支持我们的假设,即往往比必要更慷慨地选择访问修饰符。平均而言,大约三分之一的类型和方法访问修饰符属于此类别。特别是顶级类型几乎总是被声明为公共,因此包接口通常会揭示比必要的更多类型。只有2%的所有调查的顶级类型都封装在其包装内。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号