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

JavaJakarta EeArchitectureTerminologyEnterprise

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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

Solution 2 - Java

  • Class:
    it is normal java file which has .java extension and that contains all object, method or etc which are necessary to make application and also implements or extends other object or method from other file.

  • Package: It is bunch of class(.java) file which is separate by their function or their name. so it is also help for naming.

  • Module: Large applications are typically built in several parts, which are more tightly connected to each other than to the outside. Therefore, one would like to give these parts more access to each other than the outside world has. One might also want these parts reused at many points in the system without worrying about the synchronization of shared data. this part is called module in java. WAR, jar etc are called module in java language.

  • Component: A component is an identifiable part of a larger program or construction. Usually, a component provides a particular function or group of related functions. In object-oriented programming and distributed object technology, a component is a reusable program building block that can be combined with other components in the same or other computers in a distributed network to form an application. A component runs within a context called a container.

  • Container: A component runs within a context called a container.The container is an important component of Web applications in Java-based Java EE technology. It is responsible for maintaining the individual components on the server side, which include Java servlets, Java server pages(JSP) and Java server faces(JSF). How the services will be provided and accessed is determined by a contract, which is an agreement between the Web application and the container. This provides a considerable amount of security in the Java EE framework because the client applications are unaware of the existence of the container and therefore it cannot be accessed directly. Thus, the Web container is responsible for initializing Web application components and invoking client requests on the components.

  • Service: Service is an evolution of distributed computing based on the request/reply design paradigm for synchronous and asynchronous applications. An application's business logic or individual functions are modularized and presented as services for consumer/client applications.

  • Framework: Frameworks impose a definite structure on the code that uses them, whereas libraries do not. In software, framework is set of reusable software program that forms the basis for an application. Frameworks helps the programmers to build the application quickly. Earlier it was very hard to develop complex web applications. Now its very easy to develop such application using different kinds of frameworks such as Struts, Struts 2, Hibernate, JSF, Spring etc.

  • Platform: Platform refers to the entire Java development and execution environment from Sun. Java programs are executed by a runtime engine (the Java Virtual Machine) that resides in the target computer. Since Java contains its own operating environment, it has been dubbed a "platform" in contrast to other programming languages that, once compiled, run by themselves. See Java, Java 2, Java Virtual Machine and Java Runtime Environment.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongavenkoaView Question on Stackoverflow
Solution 1 - JavaRandom42View Answer on Stackoverflow
Solution 2 - JavaAngelView Answer on Stackoverflow