Java 世界中的类、包、模块、组件、容器、服务、平台 [英] Class vs package vs module vs component vs container vs service vs platform in Java world

查看:20
本文介绍了Java 世界中的类、包、模块、组件、容器、服务、平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Java 世界的新手(7 年的低级纯 C).

I am newbie to Java world (7 years of low level plain C).

当我开始阅读 Java 相关网站时:

When I started reading Java related sites:

我对现有术语感到困惑:

I confused by existing terminology:

  • 班级
  • 包装
  • 模块
  • 组件
  • 容器
  • 服务
  • 框架
  • 平台

我找到了很多关于术语定义的资源(以及更多):

I found many resources about terms definition (and a lot more):

  • Framework vs. Toolkit vs. Library
  • Difference between framework and container?
  • What are the containers in Java
  • Definition of a Java Container
  • http://martinfowler.com/articles/injection.html (Inversion of Control Containers and the Dependency Injection pattern)
  • http://www.cafeaulait.org/course/week8/36.html (What is a AWT Container?)
  • http://en.wikipedia.org/wiki/Web_container
  • http://netbeans.org/features/platform/ (The NetBeans Platform)
  • What is meant by "application framework"?
  • What is a software framework?
  • What is the difference between a framework and a library?
  • What is the difference between a class library and a framework
  • https://stackoverflow.com/questions/11576018/what-is-the-difference-between-a-javascript-framework-and-a-library
  • What is the major difference between a framework and a toolkit?
  • http://blog.orderharmony.com/2011/07/libraries-vs-frameworks.html
  • http://www.javacodegeeks.com/2012/04/frameworks-vs-libraries-as-inheritance.html
  • Difference between library, platform and framework?
  • What is the difference between a platform and a framework?
  • what is the difference between a framework and a platform
  • Difference between a module, library and a framework

但是这些资源中的每一个都根据自己的目的定义它们,我仍然无法区分例如模块和一般情况下的组件.

but each of these resources define them on its own purpose and I still can't distinct for example module from component in general case.

请从宏观角度解释这些术语的含义(可以是单类一个平台,制作一个容器需要多少模块等).

Please explain what means of these terms in big picture (can be single class a platform, what amount of modules is required to make a container, etc).

2019 年更新 来自 https://www.artima.com/lejava/articles/reuse3.html(我的突出显示)

UPDATE 2019 From https://www.artima.com/lejava/articles/reuse3.html (my highlighting)

Bill Venners:框架、平台和工具包之间有什么区别,不同的灵活性需求是什么?

Bill Venners: What is the difference between a framework, a platform, and a toolkit, and what are the different flexibility needs?

Erich Gamma:通过平台,我将长期稳定性联系在一起.在平台之上构建是安全的.平台保证兼容性.框架通常不具备这种品质,我见过许多框架稳定性方面的失败.如果您查看 Eclipse,是的,它包括框架、工具包并提供平台 API.所有这些都捆绑为插件.框架抽象并提供更高级别的默认功能.为此,框架需要处于控制之中.这种失控会导致有时称为框架炎.

Erich Gamma: With a platform I associate long term stability. It is safe to build on top of a platform. A platform makes compatibility guarantees. Frameworks often do not have this quality and I have seen many framework failures with regard to stability. If you look at Eclipse, yes it includes frameworks, toolkits, and provides platform APIs. All of this is bundled as plug-ins. Frameworks abstract and provide higher level default functionality. To do so the framework needs to be in control. This loss of control can lead to what is sometimes called frameworkitis.

Bill Venners:工具包不会因为...

Bill Venners: And toolkits don't because...

Erich Gamma:使用工具包,您可以创建和调用工具包对象并注册侦听器以对事件做出反应.您尽在掌控.框架试图控制并告诉您何时该做什么.工具包为您提供构建块,但由您来控制.

Erich Gamma: With toolkits you create and call toolkit objects and register listeners to react to events. You're in control. Frameworks try to be in control and tell you when to do what. A toolkit gives you the building blocks but leaves it up to you to be in control.

另一个引文回答了我天真的问题,有多少类构成了一个框架:

Another quotation answers my naive question how many classes makes something a framework:

https://www.artima.com/lejava/articles/reuse.html

Erich Gamma:……例如,JUnit 是一个小型框架.这是你好,世界"的框架.您已经定义了 TestTestCaseTestSuite 和关系.此外,您可以通过在某处进行子类化来连接到框架.他们使用所谓的好莱坞原则不要打电话给我们,我们会打电话给你".该框架允许您定义自定义行为,并在轮到您做某事时给您回电.和 JUnit 一样,对吧?当它想为您执行测试时,它会给您回电,但其余的工作都在框架中完成.

Erich Gamma: ... JUnit is a small framework, for example. It is the "Hello, world" of frameworks. You have Test, TestCase, TestSuite and relationships defined. Also, you hook into frameworks by subclassing somewhere. They use the so-called Hollywood principle of "don't call us, we'll call you." The framework allows you to define your custom behavior, and it will call you back when it's your turn to do something. Same with JUnit, right? It calls you back when it wants to execute a test for you, but the rest is done in the framework.

推荐答案

class类是基于类的面向对象编程中创建对象的蓝图;在学习任何有关 Java 的知识之前,您应该学习 OOP 的基础知识并了解什么是对象、什么是类、什么是继承、多态性、封装.

class A class is the blueprint for creating objects in class-based object-oriented programming; you should learn the basics of OOP and understand what an object is, what a class is, what is inheritance, polymorphism, encapsulation before learning anything else about Java.

包是一个命名空间;它让你处理命名冲突.它基本上允许你有两个名为 Employee 的类,如果它们在不同的包中.

package A package is a namespace; it let's you handle naming conflicts. It basically lets you have two classes named Employee, if they are in different packages.

module 大概是指 Java 库的分发和使用方式——JAR、WAR、EAR.

module It probably refers to the way that Java libraries are distributed and used - JAR, WAR, EAR.

component 可以看成是AWT中GUI的基类(或者Swing中的JComponent),也可以看成是一种EJB——满足一些需求的POJO(Plain Old Java Object);可能有其他含义,具体取决于上下文.

component Can be regarded as the base class of GUI in AWT (or JComponent in Swing) or can be seen as a type of EJB - a POJO (Plain Old Java Object) that meets some requirements; it is possible to have other meanings and depends on context.

container 在企业应用程序中,您显然最终会使用一些库和 Java EE;Java EE 库的问题在于它只提供 API 接口而不提供实现.然后,将您编写和构建的应用程序部署到一个 container 服务器中,该服务器随 Java EE API 的实现一起提供.有两种类型的容器:Web 容器(仅涉及 Web 特定技术的实现)和完整的 Java EE 容器(带有 Web 和其他 Java EE 技术的实现 - 命名服务、持久性、事务等).

container In enterprise application you obviously use some libraries and Java EE eventually; the thing about the Java EE library is that it only provides the API interface and not implementation. Then, the application you have written and built is deployed into a container server which comes with the implementation of the Java EE API. There are two types of containers: web containers (only comes to implementation of web specific technologies) and full Java EE containers (comes with implementation of web and other Java EE technologies - naming services, persistence, transactions etc).

service Java 中没有特殊含义.它可能与 Web 服务有关,它基本上提供了网络上进程间通信的高级方法.

service There is no special meaning in Java. It may be related to web services which basically provide a high-level approach of Inter Process Communication over network.

platform 在Java中没有特殊含义;它可以被视为底层开发平台(Windows、Linux),或者随着云趋势的发展,它可以指平台即服务,其中云提供商提供基础设施和其他基础软件(操作系统、数据库、容器).

platform There is no special meaning in Java; it can be seen as the underlying developing platform (Windows, Linux) or with the cloud trend it may refer to Platform-as-a-Service where the cloud provider comes with the infrastructure and other basic software (OS, database, container).

这篇关于Java 世界中的类、包、模块、组件、容器、服务、平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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