diff --git a/Planung.md b/Planung.md new file mode 100644 index 00000000..a35e81aa --- /dev/null +++ b/Planung.md @@ -0,0 +1,42 @@ +Architektur Planung + +1. 16.3 +2. 23.3 +3. 30.3 + +**Ostern** + +4. 13.4 +5. 20.4 +6. 27.4 +7. 4.5 +8. 11.5 + +**Christi Himmelfahrt** + +9. 25.5 +10. 1.6 + +**Fronleichnam** + +11. 15.6 +12. 22.6 +13. 29.6 + +Themen: +1. Organisation und Einführung +2. Bausteine: Schnittstellen +3. Designprinzipien +4. Bausteine: Komponenten +5. Strukturierung von Komponenten +6. Idiome in Java +7. Design Patterns I +8. Design Patterns II +9. Design Patterns III +10. Design Patterns IV +11. UI Patterns +12. Persistenz +13. Systemarchitekturen +14. Architekturtests + + diff --git a/doc/uml/slides/berechtigungen.puml b/doc/uml/slides/berechtigungen.puml new file mode 100644 index 00000000..25e606d9 --- /dev/null +++ b/doc/uml/slides/berechtigungen.puml @@ -0,0 +1,78 @@ +@startuml + +skinparam componentStyle uml2 +hide stereotype +skinparam defaultTextAlignment center + +skinparam ArrowColor black + +skinparam interface { + BorderColor black + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} + +skinparam DefaultFontSize 20 + +skinparam component { + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 + + BorderColor black + + BackgroundColor<> #salmon + StereotypeFontColor<> #white + FontColor<> #white + + BackgroundColor<> #lightGreen + StereotypeFontColor<> #black + FontColor<> #black + + BackgroundColor<> #gold + StereotypeFontColor<> #black + FontColor<> #black + + BackgroundColor<<0>> #deepskyblue + StereotypeFontColor<<0>> #white + FontColor<<0>> #white + + BackgroundColor<> #sienna + StereotypeFontColor<> #white + FontColor<> #white + + FontName Arial Black + StereotypeFontName Arial Black +} + +[ZPA] <> as ZPA +ZPA <. :Person: : \t +component Berechtigungen { + +[Berechtigungen\nStammdatenverwaltung\nDialoge] <> as GUI +[Berechtigungen\nAnwendungskern] <> as Anwendungskern +[Berechtigungen\nPersistenz] <> as Persistenz +[JDBC] <> as JDBC + +interface A +interface O +} + +Anwendungskern - A : Administrative\nSchnittstelle +O - Anwendungskern : Operative\nSchnittstelle +A <. GUI +Anwendungskern ..> Persistenz +Persistenz .> JDBC + +:Admin: ..> GUI +ZPA ..> O + + +@enduml diff --git a/doc/uml/slides/class-lehrkraft.puml b/doc/uml/slides/class-lehrkraft.puml new file mode 100644 index 00000000..7cc4815b --- /dev/null +++ b/doc/uml/slides/class-lehrkraft.puml @@ -0,0 +1,29 @@ +@startuml + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} +skinparam classFontSize 24 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 20 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle + +class Lehrkraft { + -vorname: String + -nachname: String + -email<>: String + /berechnet: String + -hatForschungsProfessur: Boolean = false +} + +@enduml diff --git a/doc/uml/slides/interface-import-lollipop.puml b/doc/uml/slides/interface-import-lollipop.puml new file mode 100644 index 00000000..b506250f --- /dev/null +++ b/doc/uml/slides/interface-import-lollipop.puml @@ -0,0 +1,58 @@ +@startuml + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 28 +} + +skinparam classFontSize 28 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 28 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +skinparam interface { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 24 +} + +skinparam classFontSize 28 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 28 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle + +circle Serializable + +hide Serializable fields + +class Person { + -name: String + -email<>: String + +getName(): String + +getEmail(): String +} + +class Repository { + +save() +} + +Repository --( Serializable +Serializable - Person : \t + + +@enduml diff --git a/doc/uml/slides/interface-import.puml b/doc/uml/slides/interface-import.puml new file mode 100644 index 00000000..b01ededa --- /dev/null +++ b/doc/uml/slides/interface-import.puml @@ -0,0 +1,45 @@ +@startuml + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 28 +} + +skinparam classFontSize 28 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 28 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle + +interface Serializable <> { + writeObject(out: ObjectOutputStream) + readObject(in: ObjectInputStream) +} + +hide Serializable fields + +class Person { + -name: String + -email<>: String + +getName(): String + +getEmail(): String +} + +class Repository { + +save() +} + +Repository ..> Serializable: "<>" + +Serializable <|. Person : \t + + +@enduml diff --git a/doc/uml/slides/interface.puml b/doc/uml/slides/interface.puml new file mode 100644 index 00000000..9ded110c --- /dev/null +++ b/doc/uml/slides/interface.puml @@ -0,0 +1,47 @@ +@startuml + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 28 +} + +skinparam classFontSize 28 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 28 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle + +interface Serializable <> { + writeObject(out: ObjectOutputStream) + readObject(in: ObjectInputStream) +} + +hide Serializable fields + +class Person { + -vorname: String + -nachname: String + -email<>: String + +getName(): String + +getEmail(): String +} + +Serializable <|.. Person +class Lehrkraft { + /berechnet: String + -hatForschungsProfessur: Boolean = false + setSprechstunde(tag: Tag, beginn: Uhrzeit) +} + +Person <|-- Lehrkraft + + +@enduml diff --git a/doc/uml/slides/kontext-zpa.puml b/doc/uml/slides/kontext-zpa.puml new file mode 100644 index 00000000..4d82563b --- /dev/null +++ b/doc/uml/slides/kontext-zpa.puml @@ -0,0 +1,60 @@ +@startuml + +skinparam componentStyle uml2 +hide stereotype +skinparam defaultTextAlignment center + +skinparam actor { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> #FFFF00 + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} + +skinparam component { + BackgroundColor #f8f8f8 + BorderColor #a0a0a0 + BackgroundColor<
> #FFFF00 + BorderColor black + FontName Arial Unicode MS + FontSize 20 + ArrowFontName Arial Unicode MS + ArrowFontSize 18 +} + +:Lehrkraft: +:Teilnehmer: + +[ZPA] <
> +[Shibboleth] +[Primuss] +[LRZ\nSMTP\nServer] as SMTP + +Lehrkraft --> ZPA : Sprechstunde +Lehrkraft --> ZPA : Kursdaten +Lehrkraft -> ZPA : Raumbuchung +ZPA -> Lehrkraft : Kursbelegung + +ZPA --> SMTP : Email Benachrichtigung +ZPA --> Shibboleth : Zugangsdaten +ZPA <-- Shibboleth : Zugangstoken + +ZPA --> Primuss : Prüfungsanmeldung +:Teilnehmer: --> ZPA : Kursprioritäten +:Teilnehmer: <-- ZPA : Stundenplan +:Teilnehmer: --> ZPA : Prüfungsanmeldung + +@enduml diff --git a/doc/uml/slides/raum-buchen-einfach.puml b/doc/uml/slides/raum-buchen-einfach.puml new file mode 100644 index 00000000..b1330830 --- /dev/null +++ b/doc/uml/slides/raum-buchen-einfach.puml @@ -0,0 +1,54 @@ +@startuml + +skinparam package { + BackgroundColor #dddddd + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} +skinparam classFontSize 24 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 20 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle + +class Person { + -vorname: String + -nachname: String + -email<>: String +} + +class Raum { + -name<>: String + -anzahlTafeln: Integer + -anzahlBeamer: Integer + -sitzplätze: Integer +} + +class RaumBuchung { + -erstellungsDatum: Date + -belegung: Zeitraum + -beschreibung: String + -status: BuchungsStatus +} + +Person "*" - "*" Raum : \t\t +(Person, Raum) . RaumBuchung : \t\t\t + +@enduml diff --git a/doc/uml/slides/raum-buchen-komplexer.puml b/doc/uml/slides/raum-buchen-komplexer.puml new file mode 100644 index 00000000..44cd7f1c --- /dev/null +++ b/doc/uml/slides/raum-buchen-komplexer.puml @@ -0,0 +1,66 @@ +@startuml + +skinparam package { + BackgroundColor #dddddd + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} + +skinparam class { + BackgroundColor #4AD386 + BorderColor #a0a0a0 + BackgroundColor<
> gold + BorderColor black + ArrowColor black + FontName Arial Unicode MS + FontSize 20 +} +skinparam classFontSize 24 +skinparam classAttributeIconSize 0 +skinparam defaultFontSize 20 + +skinparam ArrowColor black +skinparam ArrowThickness 2 + +hide circle +package "Nutzerverwaltung " { +class Person { + -vorname: String + -nachname: String + -email<>: String +} + +class Lehrkraft { + -telefon: TelefonNummer +} + +Person <|-- Lehrkraft + +} + +package "Raumverwaltung " { +class Raum { + -name: String + -anzahlTafeln: Integer + -anzahlBeamer: Integer + -sitzplätze: Integer +} + +Raum <|-- Labor +class Labor { + -anzahlRechner: Integer +} + +class RaumBuchung { + -erstellungsDatum: Date + -belegung: Zeitraum +} + +Person "*" - "*" Raum : \t\t +(Person, Raum) . RaumBuchung +} +@enduml diff --git a/src/main/java/edu/hm/hafner/util/Option.java b/src/main/java/edu/hm/hafner/util/Option.java new file mode 100644 index 00000000..243db3a4 --- /dev/null +++ b/src/main/java/edu/hm/hafner/util/Option.java @@ -0,0 +1,72 @@ +package edu.hm.hafner.util; + +import java.io.Serializable; +import java.util.Objects; + +import com.google.errorprone.annotations.Immutable; + +/** + * An option is a key value pair. + * + * @author Ullrich Hafner + */ +@Immutable +public final class Option implements Serializable { + private static final long serialVersionUID = -6416888680799872630L; + + private final String value; + private final String key; + + /** + * Creates an entry representing a mapping from the specified key to the specified value. + * + * @param key + * the key represented by this entry + * @param value + * the value represented by this entry + */ + public Option(final String key, final String value) { + this.key = key; + this.value = value; + } + + /** + * Returns the key corresponding to this entry. + * + * @return the key corresponding to this entry + */ + public String getKey() { + return key; + } + + /** + * Returns the value corresponding to this entry. + * + * @return the value corresponding to this entry + */ + public String getValue() { + return value; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Option option = (Option) o; + return Objects.equals(key, option.key) && Objects.equals(value, option.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } + + @Override + public String toString() { + return "Option{key='" + key + '\'' + ", value='" + value + '\'' + '}'; + } +} diff --git a/src/main/java/edu/hm/hafner/util/Other.java b/src/main/java/edu/hm/hafner/util/Other.java new file mode 100644 index 00000000..be3192fb --- /dev/null +++ b/src/main/java/edu/hm/hafner/util/Other.java @@ -0,0 +1,10 @@ +package edu.hm.hafner.util; + +public class Other { + public static void main(final String[] args) { + var option = new Option("key", "value"); + + System.out.println(option); + + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java deleted file mode 100644 index 842a8a0b..00000000 --- a/src/main/java/module-info.java +++ /dev/null @@ -1,9 +0,0 @@ -module edu.hm.hafner.codingstyle { - requires java.xml; - requires org.apache.commons.lang3; - requires org.apache.commons.io; - requires com.github.spotbugs.annotations; - requires com.google.errorprone.annotations; - - exports edu.hm.hafner.util; -} diff --git a/src/test/java/edu/hm/hafner/util/LspTest.java b/src/test/java/edu/hm/hafner/util/LspTest.java new file mode 100644 index 00000000..500979ef --- /dev/null +++ b/src/test/java/edu/hm/hafner/util/LspTest.java @@ -0,0 +1,31 @@ +package edu.hm.hafner.util; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.*; + +/** + * Shows that the JDK does know nothing about Liskov substitution principle. + * + * @author Ullrich Hafner + */ +public class LspTest { + @Test + void shouldValidateLiskovSubstitutionPrinciple() { + List emptyList = createList(); + + assertThat(emptyList).containsExactly("LSP"); + + emptyList.clear(); + assertThat(emptyList).isEmpty(); + } + + protected List createList() { + var list = new ArrayList(); + list.add("LSP"); + return list; + } +} diff --git a/src/test/java/edu/hm/hafner/util/LspViolatedTest.java b/src/test/java/edu/hm/hafner/util/LspViolatedTest.java new file mode 100644 index 00000000..0ef9eb87 --- /dev/null +++ b/src/test/java/edu/hm/hafner/util/LspViolatedTest.java @@ -0,0 +1,18 @@ +package edu.hm.hafner.util; + +import java.util.List; + +import org.junit.jupiter.api.Disabled; + +/** + * Shows that the JDK does know nothing about Liskov substitution principle. + * + * @author Ullrich Hafner + */ +@Disabled("This test is only for demonstration purposes") +class LspViolatedTest extends LspTest { + @Override + protected List createList() { + return List.of("LSP"); + } +} diff --git a/src/test/java/edu/hm/hafner/util/OptionFullTest.java b/src/test/java/edu/hm/hafner/util/OptionFullTest.java new file mode 100644 index 00000000..d95fddea --- /dev/null +++ b/src/test/java/edu/hm/hafner/util/OptionFullTest.java @@ -0,0 +1,66 @@ +package edu.hm.hafner.util; + +import org.junit.jupiter.api.Test; + +import nl.jqno.equalsverifier.EqualsVerifier; + +import static org.assertj.core.api.Assertions.*; + +/** + * Tests the class {@link Option}. + * + * @author Ullrich Hafner + */ +class OptionFullTest extends SerializableTest