Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jordine/se3sose2022vorlesung
  • jr125/se3sose2022vorlesung
  • lb189/se3sose2022vorlesung
  • mb345/se3sose2022vorlesung
4 results
Show changes
<!DOCTYPE html>
<html>
<head>
<title>Schnittstellen</title>
<meta charset="utf-8">
<link href="css/hdm.css" rel="stylesheet"></link>
<style>
/* yanone-kaffeesatz-regular - latin */
@font-face {
font-family: 'Yanone Kaffeesatz';
font-style: normal;
font-weight: 400;
src: url('fonts/yanone-kaffeesatz-v22-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/yanone-kaffeesatz-v22-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/yanone-kaffeesatz-v22-latin-regular.svg#YanoneKaffeesatz') format('svg'); /* Legacy iOS */
}
/* noto-serif-regular - latin */
@font-face {
font-family: 'Noto Serif';
font-style: normal;
font-weight: 400;
src: url('fonts/noto-serif-v20-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/noto-serif-v20-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/noto-serif-v20-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/noto-serif-v20-latin-regular.svg#NotoSerif') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-regular - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-regular.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-italic - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: italic;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-italic.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-italic.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-italic.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-700 - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 700;
src: url('fonts/ubuntu-mono-v14-latin-700.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-700.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
body { font-family: 'Noto Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle, first
# Software-Entwicklung 3
## Schnittstellen
---
# Agenda
1. Recap
2. Synchrone Schnittstellen
3. Asynchrone Schnittstellen
---
# Recap: Was haben wir in der letzten Vorlesung besprochen?
* SQL
* NoSQL
> Blick ins [Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022projekt)
---
class: center, middle
# Welche Formen der Kommunikationsbeziehungen kennen Sie in der (objektorientierten) Programmierung?
---
# Kommunikationsbeziehungen
Beispiele:
* lokale Schnittstellen
* API (lokal)
* Remote Schnittstellen
* RPC
* RESTful-APIs
* SOAP-APIs
* Messaging-APIs/Event-based APIs
---
# Gruppierung der Schnittstellenarten
## Synchrone Schnittstellen
## Asynchrone Schnittstellen
---
# Definition synchrone Schnittstelle
> Der Sender **blockiert** bis vom Empfänger eine Antwort geschickt wurde.
## Beispiele für synchrone Kommunikation
* HTTP
* SOAP
* GraphQL
* RPC (z.B. RMI, gRPC)
* REST
---
# Ablauf synchrone Schnittstelle (vereinfacht)
## Sender
1. Verfassen einer Nachricht
2. Verpacken der Nachricht (_Marshalling_)
3. Absenden der Nachricht
4. _Warten auf Antwort_
5. Empfangen der Antwort-Nachricht
6. Auspacken der Antwort-Nachricht
7. Verarbeiten der Antwort-Nachricht
---
# Ablauf synchrone Schnittstelle (vereinfacht)
## Empfänger
1. _Warten auf eingehende Nachrichten_
2. Empfangen der Nachricht
3. Auspacken der Nachricht
4. Verarbeiten der Nachricht
5. Verfassen der Antwort-Nachricht
6. Verpacken der Antwort-Nachricht
7. Verschicken der Antwort-Nachricht
---
# Ablauf synchrone Schnittstelle
**Neu!**
> Blick ins [Vorlesungs-Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022vorlesung)
---
# Was ist REST?
> REST: Representational State Transfer
Softwarearchitekturstil
---
# Grundprinzipien
_nach [Wikipedia, 2022](https://de.wikipedia.org/wiki/Representational_State_Transfer)_
* Client/Server
* Zustandslosigkeit
* Caching
* Einheitliche Schnittstelle
* Adressierbarkeit von Ressourcen
* Repräsentationen zur Veränderung von Ressourcen
* Selbstbeschreibende Nachrichten
* „Hypermedia as the Engine of Application State“ (HATEOAS)
* Mehrschichtige Systeme
* Code on Demand (optional)
---
# REST-URIs
> URI: Uniform Resource Identifier
Mögliche URI-Muster:
* `<protocol>://<service-name>/<resource-type>/<resource-id>`
* `<resource-type>/<resource-id>`
* `<protocol>://<service-name>/<resource-type>/<resource-id>/<resource-details>`
* `<protocol>://<service-name>/<api-version>/<resource-type>/<resource-id>`
Beispiele:
* `https://music-mamager.app/songs/112233`
* `https://music-mamager.app/songs/112233/play`
* `https://music-mamager.app/songs/112233/artist`
* `/v3/songs/112233/artist/json`
---
# REST im Einsatz
* Verwendung auf Basis von HTTP/HTTPS
* Nutzen der [HTTP-Verben](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)
* `POST`
* `GET`
* `DELETE`
* `PUT` (entspricht einem Update)
* ...
* Nutzen der HTTP-Status-Codes für Antworten
* [Übersicht der HTTP-Status-Codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
---
# REST-APIs mit OpenAPI 3/Swagger
* API-Spezifikation
* API-Dokumentation
* API-Generierung
* Testumgebung
[Petstore Demo Projekt](https://petstore.swagger.io/)
---
# REST mit Spring Boot (I)
* Alternative zu `JAX-WS`
* Maven-Dependency hinzufügen (`spring-boot-starter-web`)
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.0</version>
<!-- ... -->
</dependency>
```
* Erstellen einer Klasse, die mit `@RestController` annotiert wird
* Annotieren der Methoden mit geeigneter HTTP-Verb Annotation (z.B. `@GetMapping`) und zuweisen des Resource-Pfads (z.B. `/songs`)
* Mapping der URL-Parameter zu Java-Parametern mit der `@RequestParam(value = "name", defaultValue = "Song 2")`
---
# REST mit Spring Boot (II)
Start der Anwendung:
```java
@SpringBootApplication
public class RestServiceApplication {
public static void main(String[] args) {
SpringApplication.run(RestServiceApplication.class, args);
}
}
```
---
# REST mit Spring Boot (III)
_Quelle: ["Building a RESTful Web Service", spring.io, 2022](https://spring.io/guides/gs/rest-service/)_
```java
package com.example.restservice;
public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
```
---
# REST mit Spring Boot (IV)
```java
package com.example.restservice;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
```
---
# REST-Demo im Projekt
> Blick ins [Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022projekt)
---
class: center, middle
# Asynchrone Kommunikationsbeziehungen
---
# Definition asynchrone Schnittstelle
> Sender **blockiert nicht** bis vom Empfänger eine Antwort geschickt wurde.
## Beispiele asynchrone Kommunikation
* Chats
* E-Mail
* Message Broker/Queues (implementierungsabhängig)
---
# Message Broker
_nach: "Learn Microservices with Spring Boot", Moisés Macero García, apress, 2020, S. 216_
<img alt="Schematische Darstellung Message Broker" src="img/schnittstellen/message_broker.png" width="100%"/>
---
# Ablauf asynchrone Schnittstelle (vereinfacht)
## Sender
1. Verfassen einer Nachricht
2. Verpacken der Nachricht (_Marshalling_)
3. Absenden der Nachricht
4. _Weiter im Programmfluss_
5. _Ggf. Empfangen der Antwort-Nachricht (nach Zeitraum X)_
6. _Ggf. Auspacken der Antwort-Nachricht_
7. _Ggf. Verarbeiten der Antwort-Nachricht_
---
# Ablauf asynchrone Schnittstelle (vereinfacht)
## Empfänger
1. _Warten auf eingehende Nachrichten_
2. Empfangen der Nachricht
3. Auspacken der Nachricht
4. Verarbeiten der Nachricht
5. _Ggf. Verfassen der Antwort-Nachricht_
6. _Ggf. Verpacken der Antwort-Nachricht_
7. _Ggf. Verschicken der Antwort-Nachricht_
---
# Backup Themen: Software im Betrieb
* Eventual consistency
* Monitoring
* Logging
* Security
* Patching
* Releaseplanung
* Downtimes
* Dokumentation/Schulungen
</textarea>
<script src="js/remark.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<title>Softwarearchitektur</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
<link href="css/hdm.css" rel="stylesheet"></link>
<style>
/* yanone-kaffeesatz-regular - latin */
@font-face {
font-family: 'Yanone Kaffeesatz';
font-style: normal;
font-weight: 400;
src: url('fonts/yanone-kaffeesatz-v22-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/yanone-kaffeesatz-v22-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/yanone-kaffeesatz-v22-latin-regular.svg#YanoneKaffeesatz') format('svg'); /* Legacy iOS */
}
/* noto-serif-regular - latin */
@font-face {
font-family: 'Noto Serif';
font-style: normal;
font-weight: 400;
src: url('fonts/noto-serif-v20-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/noto-serif-v20-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/noto-serif-v20-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/noto-serif-v20-latin-regular.svg#NotoSerif') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-regular - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-regular.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-italic - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: italic;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-italic.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-italic.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-italic.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-700 - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 700;
src: url('fonts/ubuntu-mono-v14-latin-700.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-700.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
body { font-family: 'Noto Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle
class: center, middle, first
# Software-Entwicklung 3
......@@ -30,8 +93,10 @@ class: center, middle
# Agenda
1. Recap
Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Architekturmuster, Wie wird Code strukturiert?, Wie Code dokumentiert und warum ist das wichtig? UML-Klassendiagramme
2. Warum Softwarearchitektur?
3. Grundfertigkeiten Softwarearchitekt:innen
4. Basisprinzipien
5. Praktische Umsetzung im Demo-Projekt
---
......@@ -43,6 +108,8 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
* Methoden zur Anforderungsanalyse
* Projektarbeit
> Blick ins [Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022projekt)
---
# Recap: SE1 & SE2
......@@ -55,9 +122,18 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
---
# Beispiel: Lego Saturn V
<img src="img/softwarearchitektur/saturn_v_collage.jpg" width="80%"/>
---
# Warum ist Softwarearchitektur notwendig?
(Bild einfügen: "Big ball of mud")
![Big Ball of Mud](img/softwarearchitektur/big_ball_of_mud.png)
_(nach "Software-Architektur", O. Vogel, I. Arnold et al., Springer, 2009)_
---
......@@ -68,7 +144,7 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
* Aggregation
* Generalisierung/Spezialisierung
* Realisierung
---
# Warum ist Softwarearchitektur notwendig?
**Komplexität beherrschen**
......@@ -87,6 +163,8 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
* Beziehung zwischen den Bestandteile
* Gerüst auf dem Anforderungen umgesetzt werden
> Problem: Softwarearchitektur meistens nicht von "außen" ersichtlich.
---
# Grundfertigkeiten Softwarearchitekt:innen
......@@ -94,16 +172,11 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
* Generalisierung: Abstraktionsvermögen
* Zusammenhänge erkennen
* Muster kennen und erkennen
* Entwicklungserfahrung
* Spezialisierung: Zerlegung in Teilprobleme
* Zuhören
* Erfahrungsschatz: Aus Erfolgen und Fehlern lernen
* Kommunikationsfähigkeit
---
# Beispiel: Lego Saturn V
(Bilder einfügen)
* Kommunikationsfähigkeit und zuhören können
* Implizites explizit machen
---
......@@ -111,9 +184,9 @@ Was ist Softwarearchitektur?, Design Pattern Überblick, Systemarchitektur, Arch
## Software Product Quality
![Software Product Quality](img/software_product_quality.png)
<img alt="Software Product Quality" src="img/softwarearchitektur/software_product_quality.png" width="110%"/>
_nach: ISO/IEC 25010, https://iso25000.com/index.php/en/iso-25000-standards/iso-25010_
_nach: "Software Product Quality", ISO/IEC 25010, https://iso25000.com/index.php/en/iso-25000-standards/iso-25010_
---
......@@ -125,7 +198,7 @@ _nach: ISO/IEC 25010, https://iso25000.com/index.php/en/iso-25000-standards/iso-
* Herangehensweisen:
* Top-Down ("Teile und Herrsche")
* Bottom-up
* Design to test
* Design to test (TDD)
---
......@@ -133,7 +206,9 @@ _nach: ISO/IEC 25010, https://iso25000.com/index.php/en/iso-25000-standards/iso-
* Wer kommuniziert mit wem?
* Wie ist die Kommunikationsrichtung zwischen Modulen?
* Identifikation von "stabilen" Komponenten: Zählen von eingehenden Abhängigkeiten.
* Wahrung von Austauschbarkeit
* **Bitte vermeiden**: Zirkuläre Abhängigkeiten
---
......@@ -175,7 +250,6 @@ MyInterface a = new MyImplementation();
```
* Welche Variante ist besser? Warum?
* Wie heißt das Prinzip?
---
......@@ -209,21 +283,29 @@ public Person getPerson(int personId){
---
# Basisprinzip: Loose Coupling and Strong Cohesion
# Projekt: Praktische Umsetzung
* Klassendiagramm als Ausgangslage
* Identifikation möglicher Komponenten
* Pattern: (Abstract) Factory
---
# Basisprinzip: Dependency Injection
* Objekte erzeugen ihre Abhängigkeiten nicht selbst
* Dies wird von einem sog. `Injector` übernommen
* Ziel ist die Reduktion und Zentralisierung von Abhängigkeiten
> Blick ins [Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022projekt)
---
# Notes
* Umsetzen der Anforderungen in Code
* Einteilen in Packages
* Ggf. Java Modules
* Richtiges Maven Projekt wählen
* In einzeln deploybare Artefakten denken
* Stabile Teile im Code: Zählen von Abhängigkeiten
* Nach außen mit Interfaces kommunizieren
* Abstract Factory
* Issues mit Code verlinken
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
<script src="js/remark.min.js">
</script>
<script>
var slideshow = remark.create();
......
<!DOCTYPE html>
<html>
<head>
<title>SQL, NoSQL</title>
<meta charset="utf-8">
<link href="css/hdm.css" rel="stylesheet"></link>
<style>
/* yanone-kaffeesatz-regular - latin */
@font-face {
font-family: 'Yanone Kaffeesatz';
font-style: normal;
font-weight: 400;
src: url('fonts/yanone-kaffeesatz-v22-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/yanone-kaffeesatz-v22-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/yanone-kaffeesatz-v22-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/yanone-kaffeesatz-v22-latin-regular.svg#YanoneKaffeesatz') format('svg'); /* Legacy iOS */
}
/* noto-serif-regular - latin */
@font-face {
font-family: 'Noto Serif';
font-style: normal;
font-weight: 400;
src: url('fonts/noto-serif-v20-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/noto-serif-v20-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/noto-serif-v20-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/noto-serif-v20-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/noto-serif-v20-latin-regular.svg#NotoSerif') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-regular - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-regular.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-italic - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: italic;
font-weight: 400;
src: url('fonts/ubuntu-mono-v14-latin-italic.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-italic.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-italic.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-italic.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
/* ubuntu-mono-700 - latin */
@font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 700;
src: url('fonts/ubuntu-mono-v14-latin-700.eot'); /* IE9 Compat Modes */
src: local(''),
url('fonts/ubuntu-mono-v14-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/ubuntu-mono-v14-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.woff') format('woff'), /* Modern Browsers */
url('fonts/ubuntu-mono-v14-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/ubuntu-mono-v14-latin-700.svg#UbuntuMono') format('svg'); /* Legacy iOS */
}
body { font-family: 'Noto Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle, first
# Software-Entwicklung 3
## Persistenz: SQL, NoSQL
---
# Agenda
1. Recap
2. SQL
3. NoSQL
---
# Recap: Was haben wir in der letzten Vorlesung besprochen?
* Container
* CI/CD
> Blick ins [Repository](https://gitlab.mi.hdm-stuttgart.de/jordine/se3sose2022projekt)
---
class: center, middle
# Was ist Persistenz?
???
* Daten über längere Zeit bereitstellen
* Benötigt: Nichtflüchtiges Speichermedium
* Auch nach Programmabbruch müssen die Daten wieder zur Verfügung stehen
---
class: center, middle
# Warum gibt es unterschiedliche Persistenzarten?
???
* Performance
* Zugriffsarten
* Zugriffssteuerung
* Transaktionssteuerung
* Unterschiedliche Anforderungen an Verfügbarkeit, Integrität, Verlässlichkeit
---
# Was sind die Probleme zwischen OO und SQL-Datenbanken?
> Impedance Mismatch
* Datenbanken arbeiten **blockorientiert**
* OO-Programme arbeiten **satzorientiert**
**Übersetzung der Paradigmen notwendig! ➡️ ORM (Objekt-relationales Mapping)**
---
# Basiskonzepte OO & relationale DBMS
## OO
* Identität
* Zustand
* Verhalten
* Kapselung
## relationale DBMS
* Relationen
* Tupel
* Attribute
---
# Was ist SQL?
* Standard, der von relationalen DBMS (_Datenbankmanagementsysteme_) implementiert wird
* Datenbanksprache für relationale DBs, bestehend aus:
* Daten einfügen, ändern, löschen: **DML** _(Data Modification Language)_
* Daten abfragen inkl. sortieren, filtern, gruppieren etc.: **DQL** _(Data Query Language)_
* Datenschemas definieren: **DDL** _(Data Definition Language)_
* Verwalten von DB-Rechten: **DCL** _(Data Control Language)_
* Transaktionssteuerung: **TCL** _(Transaction Control Language)_
---
# Was sind Einsatzszenarien für relationale DBMS?
* Struktur der Daten bekannt
* Redundanzen und Inkosistenzen sollen vermieden werden
* Transaktionen benötigt
* ...
---
# Was ist JDBC
**Java Database Cennectivity**
* API zum Zugriff auf relationale DBMS
* Herstellerunabhängig
* Treiber für jeweiliges DBMS notwendig
---
# Was sind `PreparedStatement`s?
* Vorkompilierte Datenbankanweisungen
* Höhere Performance als "normale" DB-Anweisungen
* Mehr Sicherheit, da Typprüfung stattfindet
```java
// Alle nachfolgenden Statements beziehen sich auf MariaDB
// Der vollständige Verbindungsaufbau findet sich im Vorlesungsprojekt
// ...
PreparedStatement ps = conn.prepareStatement(
"SELECT title FROM Audiotracks WHERE artist=? AND album=?");
ps.setString(1, "Glass Animals");
ps.setString(2, "Dreamland");
ResultSet rs = ps.executeQuery();
// ...
```
---
# CRUD mit JDBC: CREATE
```java
// ...
PreparedStatement ps = conn.prepareStatement(
"INSERT INTO Audiotracks (title, path, duration,
artist, album) VALUES(?, ?, ?, ?, ?)
RETURNING id");
ps.setString(1, "Heat Waves");
ps.setString(2, "audio/heat_waves.mp3");
ps.setTime(3, Time.valueOf(LocalTime.parse("00:03:14")));
ps.setString(4, "Glass Animals");
ps.setString(5, "Dreamland");
ResultSet rs = ps.executeQuery();
if (rs.next()){
int dbId = rs.getInt("id");
}
// ...
```
---
# CRUD mit JDBC: READ
```java
// ...
PreparedStatement ps = conn.prepareStatement(
"SELECT title FROM Audiotracks WHERE artist=? AND album=?");
ps.setString(1, "Glass Animals");
ps.setString(2, "Dreamland");
ResultSet rs = ps.executeQuery();
while(rs.next()){
System.out.println(rs.getString(1));
}
// ...
```
---
# CRUD mit JDBC: UPDATE
```java
// ...
PreparedStatement ps = conn.prepareStatement(
"UPDATE Audiotracks SET album = ? WHERE album = ?;");
ps.setString(1, "Dreamland");
ps.setString(1, "DREAMLAND");
ps.execute();
// ...
```
---
# CRUD mit JDBC: DELETE
```java
// ...
PreparedStatement ps = conn.prepareStatement(
"DELETE FROM Audiotracks WHERE album = ?;");
ps.setString(1, "Dreamland");
ps.execute();
// ...
```
---
# Umgang mit Objektbeziehungen
Hintergrund: Wie können Objektbeziehungen abgebildet werden?
```java
class AudioTrack{
// ...
private Artist artist;
}
```
Schritte in der DB (ggf. mit Transaktion):
1. Erzeugen eines `Artist`-Eintrags mit `INSERT` inkl. Rückgabe der erzeugten ID mit `RETURNING`
2. Speichern der zurückgegebenen ID im `Artist`-Objekt
3. Erzeugen eines `Audiotrack`-Eintrags mit `INSERT`. Setzen der Fremdschlüssel ID auf zuvorgespeicherte `Artist`-ID.
---
# Ausblick: JPA
**Jakarta Persistence API**/**Java Persistence API**
* Vereinfachung des ORM
* POJOs (_Plain old Java Objects_) können automatisch zu Tabellen gemappt werden
* Möglichkeiten, Objektbeziehungen zu beschreiben und autmatisiert aufzulösen
---
class: center, middle
# NoSQL
---
# Was ist NoSQL?
**NoSQL = Not only SQL**
* Sammelbegriff für unterschiedliche Datenbankentypen
* Oft horizontal skalierbar
## NoSQL-Datenbanktypen
* Dokumenten-DBs: z.B. MongoDB, BaseX, CouchDB
* Graph-DBs: Neo4j
* Key-Value-DBs: Redis
* ...
---
# Einsatzszenarien
_[Wikipedia, 2022](https://de.wikipedia.org/w/index.php?title=NoSQL&oldid=220335513), nach [Scofield, B., 2010](http://www.slideshare.net/bscofield/nosql-codemash-2010)_
<img src="img/sql-nosql/sql-nosql.png" width="100%" alt="Vergleich DBMS">
---
# CRUD mit MongoDB: CREATE
_nach: https://www.mongodb.com/developer/quickstart/java-setup-crud-operations/_
```java
//...
Document audioTrack = new Document("_id", new ObjectId());
audioTrack.append("title", "Heat Waves")
.append("path", "audio/heat_waves.mp3")
.append("duration", "00:03:14")
.append("artist", "Glass Animals")
.append("album", "Dreamland");
audioTracksCollection.insertOne(audioTrack);
//...
```
---
# CRUD mit MongoDB: READ
```java
//...
Document audioTrack = audioTracksCollection.find(
new Document("audiotrack_id", 10000)).first();
System.out.println(audioTrack.toJson());
//...
```
---
# CRUD mit MongoDB: UPDATE
```java
import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Updates.*;
//...
Bson filter = eq("audiotrack_id", 10000);
Bson updateOperation = set("album", "DREAMLAND");
UpdateResult updateResult = audioTracksCollection.
updateOne(filter, updateOperation);
System.out.println(audioTracksCollection.find(
filter).first().toJson(prettyPrint));
System.out.println(updateResult);
//...
```
---
# CRUD mit MongoDB: DELETE
```java
import static com.mongodb.client.model.Filters.eq;
//...
Bson filter = eq("audiotrack_id", 10000);
DeleteResult result = gradesCollection.deleteOne(filter);
System.out.println(result);
//...
```
---
# Tipps
* Skripte zum befüllen der DB mit Demodaten bereitstellen
* Docker-Container mit DB
* SQL Inspect mit IntelliJ
</textarea>
<script src="js/remark.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>
</html>
\ No newline at end of file