Skip to content

Commit

Permalink
Relocate blocks to code quality lecture #29
Browse files Browse the repository at this point in the history
  • Loading branch information
pintergreg committed Oct 22, 2024
1 parent 3eb3b1e commit ac8b037
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 116 deletions.
116 changes: 0 additions & 116 deletions lectures/12_clean_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
<!--```ruby
a = 0
for i in 0..9 do
a += 1
puts i
end
```
```ruby
a = 0
for i in 0..9 {
a += 1
puts i
}
```-->
```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}
Expand Down
129 changes: 129 additions & 0 deletions lectures/13_code_quality.md
Original file line number Diff line number Diff line change
@@ -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"}
<!--```ruby
a = 0
for i in 0..9 do
a += 1
puts i
end
```
```ruby
a = 0
for i in 0..9 {
a += 1
puts i
}
```-->
```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]
:::
::::::

0 comments on commit ac8b037

Please sign in to comment.