Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Commit 12de92e

Browse files
Web 0.14.4: Klammern bei if („goto fail“), Heartbleed und Struktogramm nach vorne (L8) (#237)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ugz28TUvYQdhvdA4FcsREf
1 parent dd0cfcc commit 12de92e

12 files changed

Lines changed: 344 additions & 235 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The format is loosely inspired by Keep a Changelog.
1515

1616
### Added
1717

18+
- **Web 0.14.4, why we always write curly brackets:** lesson 8 step „Jetzt in Java“ has a new Angeberwissen box: Java lets you leave out `{ }` around a single statement, a short example shows the indented second line still running every time, and Apple's „goto fail“ bug (2014) shows the real consequence. Step „Ein leerer Zweig“ gets a box on Heartbleed (2014) as a forgotten if (missing length check, nothing to do with brackets). In step „Wenn, dann, sonst“ the structure chart now comes before the explanation (de/en/pt).
1819
- **Web 0.14.3, Grace Hopper with photo:** lesson 7's Angeberwissen about the moth („bug“) now says who Grace Hopper was (one of the first compilers in 1952, the idea behind COBOL, admiral in the US Navy), followed by her portrait (U.S. Navy, public domain, Commons „Commodore Grace M. Hopper, USN (covered).jpg“, 300×400). Lesson 20 gets an Angeberwissen box: she built one of the first compilers although many said computers could only do arithmetic (de/en/pt).
1920
- **Web 0.14.2, Java in the console:** lesson 20 step „Wie Java auf jedem Computer läuft“ has a new Angeberwissen box on `java -version`, `javac Einmaleins.java` and `java Einmaleins`, plus the hint that a missing `javac -version` means only a JRE is installed (de/en/pt). Fix: the two diagrams in that step were missing their closing `:::`, so in 0.14.1 the text after the first diagram showed up as its caption; they now have short captions, and a new test flags overly long captions.
2021
- **Web 0.14.1, how Java runs on every computer:** lesson 20 has a new step „Wie Java auf jedem Computer läuft“ after „Snippet oder Class“: source code → compiler `javac` → bytecode (`.class`) → JVM on Windows/macOS/Linux, platform independence („Write once, run anywhere“), the JVM pictured as a small computer made of software (but a virtual machine, not an operating system), a table JRE vs. JDK, the JVM translating bytecode into machine code (JIT compiler), and a comparison with C++ (compiled directly to machine code, so once per system; second diagram l20-cpp.svg and a C++/Java table). New self-drawn diagram l20-jvm.svg (de/en/pt), the CAFEBABE Angeberwissen moved into the new step, three competences, three checklist lines and three quiz questions. Lesson 4 „Jetzt in Java“ points to lesson 20. New glossary entries Quellcode, Compiler, Bytecode, Maschinencode, JIT-Compiler, JVM, JRE, JDK, plattformunabhängig and Nachschlagen section „Java › Vom Code zum Programm“ (de/en/pt).

‎web/lessons/de/08-verzweigung.md‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ kurz: Mit einer Bedingung entscheiden, welcher von zwei Wegen ausgeführt wird.
1818

1919
Bisher wurden alle Kästen immer ausgeführt. Oft soll ein Programm aber **entscheiden**: Wenn eine Bedingung erfüllt ist, tue das eine, sonst das andere.
2020

21+
::: diagramm l07-alter-pruefen.visustruct
22+
Je nach eingegebenem Alter erscheint die eine oder die andere Meldung. Probiere in der Simulation 17 und 18 aus.
23+
:::
24+
2125
Dafür gibt es die **Verzweigung**. Oben im Dreieck steht die Bedingung. Darunter teilt sich das Struktogramm in zwei Zweige:
2226

2327
- **true** (links): wird ausgeführt, wenn die Bedingung wahr ist
2428
- **false** (rechts): wird ausgeführt, wenn die Bedingung falsch ist
2529

2630
Es wird immer **genau einer** der beiden Zweige ausgeführt. Danach geht es unter der Verzweigung weiter.
2731

28-
::: diagramm l07-alter-pruefen.visustruct
29-
Je nach eingegebenem Alter erscheint die eine oder die andere Meldung. Probiere in der Simulation 17 und 18 aus.
30-
:::
31-
3232
## Eine Verzweigung einfügen
3333

3434
Ziehe die **Verzweigung** aus dem Bereich Elemente ins Struktogramm. Klicke das Dreieck an und schreibe im Objektinspektor die Bedingung, z. B. `alter >= 18`. Das Wort `if` steht schon davor.
@@ -84,6 +84,10 @@ Manchmal soll nur dann etwas passieren, wenn die Bedingung wahr ist, und sonst g
8484
Ab 50 Euro gibt es 5 Euro Rabatt. Sonst passiert nichts, der false-Zweig ist leer. Die Ausgabe darunter wird in beiden Fällen ausgeführt.
8585
:::
8686

87+
::: angeberwissen
88+
Eine einzige vergessene Verzweigung hat 2014 halb das Internet in Aufregung versetzt: die Sicherheitslücke **Heartbleed** in OpenSSL, einem Programm, das viele Webseiten für die Verschlüsselung benutzen. Ein Computer konnte dem Server sagen: „Schick mir das Wort *Hut* zurück, es hat 500 Buchstaben.“ Der Server hat nicht geprüft, ob die 500 zur echten Länge 3 passen, und einfach 500 Zeichen aus seinem Speicher zurückgeschickt. Darin standen manchmal Passwörter anderer Leute. Gefehlt hat nur ein if: Wenn die angegebene Länge größer ist als die echte, dann nichts zurückschicken. Mit Klammern hatte das übrigens nichts zu tun. Mäh, prüf deine Eingaben, bevor du ihnen glaubst.
89+
:::
90+
8791
## Übung: Betrag
8892

8993
::: übung l07-betrag
@@ -141,6 +145,20 @@ tipp: Die Bedingung lautet `punkte >= 50`. In den Zweigen steht `System.out.prin
141145
lösung: l08-java-bestanden-loesung.visustruct
142146
:::
143147

148+
::: angeberwissen
149+
Steht im Zweig nur eine einzige Anweisung, darf man in Java die geschweiften Klammern sogar weglassen. Wir machen das trotzdem nie, und zwar aus diesem Grund:
150+
151+
```java
152+
if (alter >= 18)
153+
System.out.println("Du bist volljährig.");
154+
System.out.println("Du darfst den Film sehen.");
155+
```
156+
157+
Ohne Klammern gehört nur die erste Zeile zum if. Die zweite läuft immer, auch für Zwölfjährige. Die Einrückung täuscht, denn Java achtet nicht auf Leerzeichen.
158+
159+
Genau so ein Fehler steckte 2014 in iPhones und Macs, bekannt als **„goto fail“**. In der Sprache C stand unter einem if ohne Klammern die Zeile `goto fail;` aus Versehen zweimal. Die zweite lief immer und übersprang die Prüfung der Sicherheitszertifikate. In einem offenen WLAN hätte sich ein Angreifer so zum Beispiel als deine Bank ausgeben können. Mäh, Klammern kosten zwei Zeichen, eine Sicherheitslücke kostet viel mehr.
160+
:::
161+
144162
## Lückentext: Gerade oder ungerade
145163

146164
::: lückentext

‎web/lessons/en/08-verzweigung.md‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ kurz: Use a condition to decide which of two paths runs.
1818

1919
So far every box always ran. But often a program should **decide**: if a condition is met, do one thing, otherwise do the other.
2020

21+
::: diagramm l07-alter-pruefen.visustruct
22+
Depending on the age typed in, one message or the other appears. Try 17 and 18 in the simulation.
23+
:::
24+
2125
That is what the **branch** is for. The condition sits in the triangle at the top. Below it, the structure chart splits into two paths:
2226

2327
- **true** (left): runs if the condition is true
2428
- **false** (right): runs if the condition is false
2529

2630
Always **exactly one** of the two paths runs. After that, the program continues below the branch.
2731

28-
::: diagramm l07-alter-pruefen.visustruct
29-
Depending on the age typed in, one message or the other appears. Try 17 and 18 in the simulation.
30-
:::
31-
3232
## Insert a branch
3333

3434
Drag the **Branch** from the Elements area into the structure chart. Click the triangle and type the condition in the Object Inspector, e.g. `age >= 18`. The word `if` is already in front.
@@ -84,6 +84,10 @@ Sometimes something should only happen if the condition is true, and otherwise n
8484
From 50 euros on, you get 5 euros off. Otherwise nothing happens; the false path is empty. The output below runs in both cases.
8585
:::
8686

87+
::: angeberwissen
88+
A single forgotten branch caused a stir across half the internet in 2014: the security hole **Heartbleed** in OpenSSL, a program that many websites use for encryption. A computer could tell the server: “Send me back the word *hat*, it has 500 letters.” The server did not check whether 500 matched the real length of 3 and simply sent back 500 characters from its memory. Sometimes they contained other people's passwords. All that was missing was one if: if the stated length is greater than the real one, then send nothing back. By the way, this had nothing to do with brackets. Baah, check your inputs before you believe them.
89+
:::
90+
8791
## Exercise: Absolute value
8892

8993
::: übung l07-betrag
@@ -141,6 +145,20 @@ tipp: The condition is `points >= 50`. One branch has `System.out.println("passe
141145
lösung: l08-java-bestanden-loesung.visustruct
142146
:::
143147

148+
::: angeberwissen
149+
If a branch holds only a single statement, Java even lets you leave out the curly brackets. We never do that, and here is why:
150+
151+
```java
152+
if (age >= 18)
153+
System.out.println("You are an adult.");
154+
System.out.println("You may watch the film.");
155+
```
156+
157+
Without brackets only the first line belongs to the if. The second one always runs, even for twelve-year-olds. The indentation is misleading, because Java ignores spaces.
158+
159+
Exactly this kind of mistake was hidden in iPhones and Macs in 2014, known as **“goto fail”**. In the language C, the line `goto fail;` accidentally appeared twice under an if without brackets. The second one always ran and skipped the check of the security certificates. On an open Wi-Fi network, an attacker could have pretended to be your bank, for example. Baah, brackets cost two characters, a security hole costs much more.
160+
:::
161+
144162
## Fill in the gaps: even or odd
145163

146164
::: lückentext

‎web/lessons/pt/08-verzweigung.md‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ kurz: Usar uma condição para decidir qual de dois ramos é executado.
1818

1919
Até agora, todos os blocos eram sempre executados. Mas muitas vezes um programa deve **decidir**: se uma condição se verificar, faz uma coisa, senão faz a outra.
2020

21+
::: diagramm l07-alter-pruefen.visustruct
22+
Consoante a idade introduzida, aparece uma mensagem ou a outra. Experimenta 17 e 18 na simulação.
23+
:::
24+
2125
É para isso que serve a **decisão**. A condição fica no triângulo em cima. Por baixo, o estrutograma divide-se em dois ramos:
2226

2327
- **true** (esquerda): é executado se a condição for verdadeira
2428
- **false** (direita): é executado se a condição for falsa
2529

2630
É sempre executado **exatamente um** dos dois ramos. Depois, o programa continua por baixo da decisão.
2731

28-
::: diagramm l07-alter-pruefen.visustruct
29-
Consoante a idade introduzida, aparece uma mensagem ou a outra. Experimenta 17 e 18 na simulação.
30-
:::
31-
3232
## Inserir uma decisão
3333

3434
Arrasta a **Decisão** da área Elementos para o estrutograma. Clica no triângulo e escreve a condição no Inspetor de objetos, p. ex. `idade >= 18`. A palavra `if` já está à frente.
@@ -84,6 +84,10 @@ lösung: l07-maximum-loesung.visustruct
8484
A partir de 50 euros tens 5 euros de desconto. Caso contrário não acontece nada; o ramo false está vazio. A saída em baixo é executada nos dois casos.
8585
:::
8686

87+
::: angeberwissen
88+
Uma única decisão esquecida deixou meia Internet em alvoroço em 2014: a falha de segurança **Heartbleed** no OpenSSL, um programa que muitos sites usam para a encriptação. Um computador podia dizer ao servidor: “Devolve-me a palavra *pão*, tem 500 letras.” O servidor não verificava se 500 correspondia ao comprimento real de 3 e devolvia simplesmente 500 caracteres da sua memória. Às vezes lá dentro estavam palavras-passe de outras pessoas. Só faltava um if: se o comprimento indicado for maior do que o real, então não devolver nada. Já agora, isto não tinha nada a ver com chavetas. Mééé, verifica as tuas entradas antes de acreditares nelas.
89+
:::
90+
8791
## Exercício: Valor absoluto
8892

8993
::: übung l07-betrag
@@ -141,6 +145,20 @@ tipp: A condição é `pontos >= 50`. Num ramo fica `System.out.println("aprovad
141145
lösung: l08-java-bestanden-loesung.visustruct
142146
:::
143147

148+
::: angeberwissen
149+
Se um ramo tiver só uma instrução, o Java até deixa tirar as chavetas. Nós nunca fazemos isso, e é por esta razão:
150+
151+
```java
152+
if (idade >= 18)
153+
System.out.println("És maior de idade.");
154+
System.out.println("Podes ver o filme.");
155+
```
156+
157+
Sem chavetas, só a primeira linha pertence ao if. A segunda é sempre executada, até para quem tem doze anos. A indentação engana, porque o Java não liga aos espaços.
158+
159+
Foi exatamente um erro destes que estava escondido em iPhones e Macs em 2014, conhecido como **“goto fail”**. Na linguagem C, a linha `goto fail;` aparecia por engano duas vezes debaixo de um if sem chavetas. A segunda era sempre executada e saltava a verificação dos certificados de segurança. Numa rede Wi-Fi aberta, um atacante podia, por exemplo, fazer-se passar pelo teu banco. Mééé, as chavetas custam dois caracteres, uma falha de segurança custa muito mais.
160+
:::
161+
144162
## Preenche os espaços: par ou ímpar
145163

146164
::: lückentext

‎web/package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎web/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "visustruct-web",
33
"private": true,
4-
"version": "0.14.3",
4+
"version": "0.14.4",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

0 commit comments

Comments
 (0)