diff --git a/lectures/figures/name_and_scope.drawio.svg b/lectures/figures/name_and_scope.drawio.svg new file mode 100644 index 0000000..aa124af --- /dev/null +++ b/lectures/figures/name_and_scope.drawio.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/slides/12_clean_code.html b/slides/12_clean_code.html index 0886e9b..1577549 100644 --- a/slides/12_clean_code.html +++ b/slides/12_clean_code.html @@ -300,9 +300,9 @@
Clean Code: A Handbook of Agile Software Craftsmanship
by Robert C. Martin (2009) [2]
-some recommendations are too specific to C-like languages
-++The longer the scope of a function, the shorter its name +should be. Functions that are called locally from a few nearby +places should have long descriptive names, and the longest function +names should be given to those functions that are called from just one +place.
+ +
“longer scope”: more general part of a code
+increaseSpeed
-Robert C. Martin The -Inverse Scope Law of Function Names: The longer the scope of a -function, the shorter its name should be. Functions that are called -locally from a few nearby places should have long descriptive names, and -the longest function names should be given to those functions that are -called from just one place.
-
-Flag arguments are ugly […] loudly proclaiming that this function -does more than one thing [2].
-
var a = 0;
+for (i = 0; i < 10; i++)
+ a++;
+ console.log(i);
parts from sslKeyExchange.c
-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;
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;
more about Apple’s “goto fail” fiasco (2014): [6], + + + \ No newline at end of file