diff --git a/lectures/12_clean_code.md b/lectures/12_clean_code.md index 3c5e79e..276bf75 100644 --- a/lectures/12_clean_code.md +++ b/lectures/12_clean_code.md @@ -1041,122 +1041,6 @@ def fizzbuzz(i: int) -> str: ::: -# denoting blocks - -:::::::::::: {.columns .column-gapless} -::::::::: {.column width="50"} -```javascript -for (i = 0; i < 10; i++) { - console.log(i); -} -``` -```javascript -for (i = 0; i < 10; i++) - console.log(i); - -``` -```javascript -var a = 0; -for (i = 0; i < 10; i++) - a++; - console.log(i); - -``` - -::::::::: -::::::::: {.column width="25%"} - -::: {.fragment data-fragment-index="1"} -```python -for i in range(10): - print(i) -``` -```python -a = 0 -for i in range(10): - a += 1 - print(i) -``` - -::: -::::::::: -::::::::: {.column width="25%"} -::: {.fragment data-fragment-index="2"} - -```go -package main - -import ( - "fmt" -) - -func main() { - for i:=0; i<10; i++ { - fmt.Println(i) - } -} -``` - -```rust -fn main() { - for i in 0..9 { - println!("{}", i); - } -} -``` -::: - -::::::::: -:::::::::::: - - -## what could go wrong? - -:::::: {.fragment} -::: {.text-smaller} -parts from [sslKeyExchange.c](https://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c?txt) -::: - -```c {.numberLines startFrom="623"} -if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0) - goto fail; -if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0) - goto fail; -if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) - goto fail; -if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) - goto fail; - goto fail; -if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) - goto fail; -``` - -```c {.numberLines startFrom="647"} -fail: - SSLFreeBuffer(&signedHashes); - SSLFreeBuffer(&hashCtx); - return err; -``` - -::: {.fragment} -more about Apple's "goto fail" fiasco (2014): [@wheeler2014apple], [@migues2014understanding] -::: -:::::: - - # references ::: {#refs} diff --git a/lectures/13_code_quality.md b/lectures/13_code_quality.md new file mode 100644 index 0000000..7653830 --- /dev/null +++ b/lectures/13_code_quality.md @@ -0,0 +1,129 @@ +--- +title: code quality +author: Gergő Pintér, PhD +date: gergo.pinter@uni-corvinus.hu +lang: en-US +title-slide-attributes: + data-background-color: "#181d37" + data-background-image: ../assets/by-sa.svg + data-background-size: 125px + data-background-position: 1.25rem calc(100% - 1.25rem) +slideNumber: "true" +showSlideNumber: "print" +revealjs-url: "../assets/reveal.js-5.1.0/" +--- + +# denoting blocks + +:::::::::::: {.columns .column-gapless} +::::::::: {.column width="50"} +```javascript +for (i = 0; i < 10; i++) { + console.log(i); +} +``` +```javascript +for (i = 0; i < 10; i++) + console.log(i); + +``` +```javascript +var a = 0; +for (i = 0; i < 10; i++) + a++; + console.log(i); + +``` + +::::::::: +::::::::: {.column width="25%"} + +::: {.fragment data-fragment-index="1"} +```python +for i in range(10): + print(i) +``` +```python +a = 0 +for i in range(10): + a += 1 + print(i) +``` + +::: +::::::::: +::::::::: {.column width="25%"} +::: {.fragment data-fragment-index="2"} + +```go +package main + +import ( + "fmt" +) + +func main() { + for i:=0; i<10; i++ { + fmt.Println(i) + } +} +``` + +```rust +fn main() { + for i in 0..9 { + println!("{}", i); + } +} +``` +::: + +::::::::: +:::::::::::: + + +## what could go wrong? + +:::::: {.fragment} +::: {.text-smaller} +parts from [sslKeyExchange.c](https://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c?txt) +::: + +```c {.numberLines startFrom="623"} +if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0) + goto fail; +if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0) + goto fail; +if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) + goto fail; +if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) + goto fail; + goto fail; +if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) + goto fail; +``` + +```c {.numberLines startFrom="647"} +fail: + SSLFreeBuffer(&signedHashes); + SSLFreeBuffer(&hashCtx); + return err; +``` + +::: {.fragment} +more about Apple's "goto fail" fiasco (2014): [@wheeler2014apple], [@migues2014understanding] +::: +::::::