Subject - crowlogic/arb4j GitHub Wiki

Subject-Oriented Programming

According to The Free On-line Dictionary of Computing, a subject in subject-oriented programming is defined as follows:

  1. Collection of Classes or Class Fragments: A subject is comprised of classes or parts of classes, each modeling a specific domain in a unique way within the subject.

  2. Subjective Modeling of Domain: Subjects model their respective domains subjectively. This means the same conceptual element might have different representations across subjects.

  3. Subjects as Complete or Incomplete Applications: Subjects can either be standalone applications or incomplete fragments. This allows them to be developed in isolation or combined with other subjects for more complex applications.

  4. Subject Composition: A key feature where subjects are combined to create new ones. Class hierarchies from original subjects are merged, integrating their functionalities.

  5. Modeling of Functionality Through Class Hierarchies: Functionality and behavior within a subject are encapsulated in its class hierarchy, representing the subject's view of its domain.

Subject-oriented programming emphasizes modularization and flexibility, suitable for complex applications with distinct parts requiring different views or data models.

Subject-Oriented Programming vs. Java Packages

Subject-oriented programming and Java packages have similarities but also distinct differences:

Modularity

  • Subjects: Create modular code by organizing around specific application aspects or 'subjects'.
  • Java Packages: Also used for modularity, organizing classes, interfaces, and sub-packages based on functionality.

Encapsulation of Concerns

  • Subjects: Focus on a specific aspect of the application, potentially across different class hierarchies.
  • Java Packages: More about organizing classes based on functionality and scope.

Composition

  • Subjects: Emphasize the composition of new functionalities by merging class hierarchies.
  • Java Packages: Primarily for organization; don't inherently offer mechanisms for merging functionalities.

Scope and Namespace Management

  • Java Packages: Serve as a namespace mechanism to avoid name conflicts and control access (public, protected, etc.).
  • Subjects: While also dealing with scope, they focus more on the conceptual organization of application parts.

Application Structure

  • Subjects: Can represent complete applications or parts, focusing on conceptual organization.
  • Java Packages: Organize components of one or more applications, not inherently representing the structure of an application.

In summary, while both provide modularity and organization, subject-oriented programming is more about conceptual composition and aspect representation, whereas Java packages are structural features for organizing classes, managing namespaces, and controlling access within applications.