Class vs package vs module vs component vs container vs service vs platform in Java world

gavenkoa picture gavenkoa · Oct 31, 2012 · Viewed 31.7k times · Source

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

When I started reading Java related sites:

I confused by existing terminology:

  • class
  • package
  • module
  • component
  • container
  • service
  • framework
  • platform

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

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).

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

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

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: And toolkits don't because...

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 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.

Answer

Random42 picture Random42 · Oct 31, 2012

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.

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 It probably refers to the way that Java libraries are distributed and used - JAR, WAR, EAR.

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 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 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 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).