Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is loosely inspired by Keep a Changelog.

### Added

- **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).
- **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).
- **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.
- **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).
Expand Down
26 changes: 22 additions & 4 deletions web/lessons/de/08-verzweigung.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ kurz: Mit einer Bedingung entscheiden, welcher von zwei Wegen ausgeführt wird.

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.

::: diagramm l07-alter-pruefen.visustruct
Je nach eingegebenem Alter erscheint die eine oder die andere Meldung. Probiere in der Simulation 17 und 18 aus.
:::

Dafür gibt es die **Verzweigung**. Oben im Dreieck steht die Bedingung. Darunter teilt sich das Struktogramm in zwei Zweige:

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

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

::: diagramm l07-alter-pruefen.visustruct
Je nach eingegebenem Alter erscheint die eine oder die andere Meldung. Probiere in der Simulation 17 und 18 aus.
:::

## Eine Verzweigung einfügen

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.
Expand Down Expand Up @@ -84,6 +84,10 @@ Manchmal soll nur dann etwas passieren, wenn die Bedingung wahr ist, und sonst g
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.
:::

::: angeberwissen
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.
:::

## Übung: Betrag

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

::: angeberwissen
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:

```java
if (alter >= 18)
System.out.println("Du bist volljährig.");
System.out.println("Du darfst den Film sehen.");
```

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.

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.
:::

## Lückentext: Gerade oder ungerade

::: lückentext
Expand Down
26 changes: 22 additions & 4 deletions web/lessons/en/08-verzweigung.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ kurz: Use a condition to decide which of two paths runs.

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

::: diagramm l07-alter-pruefen.visustruct
Depending on the age typed in, one message or the other appears. Try 17 and 18 in the simulation.
:::

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:

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

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

::: diagramm l07-alter-pruefen.visustruct
Depending on the age typed in, one message or the other appears. Try 17 and 18 in the simulation.
:::

## Insert a branch

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.
Expand Down Expand Up @@ -84,6 +84,10 @@ Sometimes something should only happen if the condition is true, and otherwise n
From 50 euros on, you get 5 euros off. Otherwise nothing happens; the false path is empty. The output below runs in both cases.
:::

::: angeberwissen
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.
:::

## Exercise: Absolute value

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

::: angeberwissen
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:

```java
if (age >= 18)
System.out.println("You are an adult.");
System.out.println("You may watch the film.");
```

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.

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.
:::

## Fill in the gaps: even or odd

::: lückentext
Expand Down
26 changes: 22 additions & 4 deletions web/lessons/pt/08-verzweigung.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ kurz: Usar uma condição para decidir qual de dois ramos é executado.

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.

::: diagramm l07-alter-pruefen.visustruct
Consoante a idade introduzida, aparece uma mensagem ou a outra. Experimenta 17 e 18 na simulação.
:::

É 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:

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

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

::: diagramm l07-alter-pruefen.visustruct
Consoante a idade introduzida, aparece uma mensagem ou a outra. Experimenta 17 e 18 na simulação.
:::

## Inserir uma decisão

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.
Expand Down Expand Up @@ -84,6 +84,10 @@ lösung: l07-maximum-loesung.visustruct
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.
:::

::: angeberwissen
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.
:::

## Exercício: Valor absoluto

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

::: angeberwissen
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:

```java
if (idade >= 18)
System.out.println("És maior de idade.");
System.out.println("Podes ver o filme.");
```

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.

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.
:::

## Preenche os espaços: par ou ímpar

::: lückentext
Expand Down
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "visustruct-web",
"private": true,
"version": "0.14.3",
"version": "0.14.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Loading
Loading