Migration Deep Dive für 11 · Java-Grundlagen öffnen →
⌂ ÜbersichtAlle Vergleiche
Modul 11 · 100 % Codeabdeckung

Java-Grundlagen

Vollständiger Legacy-Modern-Vergleich aller Java-Klassen, Tests, Maven-POMs und relevanten Ressourcen dieses Moduls. Jede Datei ist genau einmal einer fachlich passenden Vergleichsgruppe zugeordnet.

4Legacy-Dateien
5Modern-Dateien
102 → 80Codezeilen
10/10vollständig erfasst

Fachliche Einordnung

Legacy

Mutable JavaBean-Klasse

Felder, Konstruktor, Getter, Setter, equals/hashCode und toString werden manuell gepflegt.

Modern

Record und Enum

Ein Record bildet unveränderliche Daten kompakt ab; der Status ist ein Enum statt freier Text.

Vergleichsfokus: Alle Dateien werden nach technischer Rolle und fachlicher Verantwortung gruppiert.
Wichtige Abgrenzung: One-to-many-Änderungen werden als Gruppe dargestellt; eine künstliche 1:1-Zuordnung wird vermieden.

Vollständige Abdeckungsmatrix

Die Ähnlichkeit ist eine technische Orientierung auf normalisiertem Quelltext. Sie ersetzt keine fachliche Bewertung.

VergleichsgruppeLegacy-DateienModern-DateienLegacy-ZeilenModern-ZeilenÄhnlichkeit
Build-Konfiguration113434100%
Bootstrap11141064%
Domänenmodell und Test2354369%

Gemeinsame Modulstruktur

Das Pair-POM bindet die Legacy- und Modern-Submodule zusammen und gehört deshalb ebenfalls zur vollständigen Codeabdeckung.

Gemeinsam · 19 Zeilenpom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.aydin.academy</groupId>
        <artifactId>java-modernization-deep-dive</artifactId>
        <version>1.0.0</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <artifactId>11javabasics-pair</artifactId>
    <packaging>pom</packaging>
    <name>Java-Grundlagen: Legacy und Modern</name>
    <modules>
        <module>legacy</module>
        <module>modern</module>
    </modules>
</project>

Alle semantischen Codevergleiche

01Build-KonfigurationDirektvergleich · Legacy 34 / Modern 34 Zeilen · Ähnlichkeit 100%

Java-/JUnit-Konfiguration wird verglichen.

Legacy-DateienModern-DateienEinordnung
pom.xmlpom.xmlDirektvergleich
Semantische Ähnlichkeit: 100%

Legacy

Legacy · 34 Zeilenlegacy/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <parent>
                <groupId>at.aydin.academy</groupId>
                <artifactId>11javabasics-pair</artifactId>
                <version>1.0.0</version>
                <relativePath>../pom.xml</relativePath>
            </parent>
            <artifactId>java-basics-legacy</artifactId>
            <packaging>jar</packaging>
            <name>Java Basics Legacy</name>

            <dependencies>

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <scope>test</scope>
</dependency>

            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>

                </plugins>
            </build>
        </project>

Modern

Modern · 34 Zeilenmodern/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <parent>
                <groupId>at.aydin.academy</groupId>
                <artifactId>11javabasics-pair</artifactId>
                <version>1.0.0</version>
                <relativePath>../pom.xml</relativePath>
            </parent>
            <artifactId>java-basics-modern</artifactId>
            <packaging>jar</packaging>
            <name>Java Basics Modern</name>

            <dependencies>

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <scope>test</scope>
</dependency>

            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>

                </plugins>
            </build>
        </project>
02BootstrapDirektvergleich · Legacy 14 / Modern 10 Zeilen · Ähnlichkeit 64%

Startprogramme zeigen die Verwendung des Modells.

Legacy-DateienModern-DateienEinordnung
BasicsLegacyApplication.javaBasicsModernApplication.javaDirektvergleich
Semantische Ähnlichkeit: 64%

Legacy

package at.aydin.lab.basics.legacy;

public final class BasicsLegacyApplication {
    private BasicsLegacyApplication() {
    }

    public static void main(String[] args) {
        LegacyCustomer customer = new LegacyCustomer();
        customer.setId(42L);
        customer.setName("Aydin");
        customer.setStatus("ACTIVE");
        System.out.println(customer.displayText());
    }
}

Modern

03Domänenmodell und TestDirektvergleich · Legacy 54 / Modern 36 Zeilen · Ähnlichkeit 9%

Mutable Klasse wird mit Record/Enum-orientiertem Modell und Tests verglichen.

Legacy-DateienModern-DateienEinordnung
LegacyCustomer.java
LegacyCustomerTest.java
Customer.java
CustomerStatus.java
CustomerTest.java
Direktvergleich
Semantische Ähnlichkeit: 9%

Legacy

package at.aydin.lab.basics.legacy;

// Design Pattern: JavaBean
// Zweck: Historische mutable Datenstruktur mit leerem Konstruktor und Settern.
public class LegacyCustomer {
    private long id;
    private String name;
    private String status;
    public LegacyCustomer() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String displayText() {
        return id + ": " + name + " [" + status + "]";
    }
}
package at.aydin.lab.basics.legacy;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

class LegacyCustomerTest {
    @Test
    void formatsMutableCustomer() {
        LegacyCustomer c = new LegacyCustomer();
        c.setId(1);
        c.setName("Test");
        c.setStatus("ACTIVE");
        assertEquals("1: Test [ACTIVE]", c.displayText());
    }
}

Modern

package at.aydin.lab.basics.modern;

// Design Pattern: Value Object
// Zweck: Unveränderliche, validierte fachliche Daten mit wertbasierter Gleichheit.
public record Customer(long id, String name, CustomerStatus status) {
    public Customer {
        if (id <= 0) throw new IllegalArgumentException("id muss positiv sein");
        if (name == null || name.isBlank()) throw new IllegalArgumentException("name fehlt");
        if (status == null) throw new IllegalArgumentException("status fehlt");
    }

    public String displayText() {
        return "%d: %s [%s]".formatted(id, name, status);
    }
}
package at.aydin.lab.basics.modern;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class CustomerTest {
    @Test
    void validatesAndFormatsRecord() {
        assertEquals("1: Test [ACTIVE]", new Customer(1, "Test", CustomerStatus.ACTIVE).displayText());
    }

    @Test
    void rejectsBlankName() {
        assertThrows(IllegalArgumentException.class, () -> new Customer(1, "", CustomerStatus.ACTIVE));
    }
}
⌂ Cockpit