@@ -1185,6 +1185,104 @@ Test passed.
11851185:::::::::
11861186::::::::::::
11871187
1188+ # summary
1189+
1190+ - bear in mind that the code is more often read than written
1191+ - make your intentions clear
1192+ - use the language properly as it's intended
1193+ - write idiomatic code
1194+ - follow the (style) guides, and best practices
1195+ - hierarchy
1196+
1197+ ## clean code / meaningful names [ @martin2009clean ]
1198+
1199+ :::::::::::: {.columns}
1200+ ::::::::: {.column width="60%"}
1201+
1202+ - use intention-revealing names
1203+ - pick one word per concept
1204+ - avoid disinformation
1205+ - make meaningful distinctions
1206+ - d[ on't use names like ` doSomething() ` and ` doSomething2() ` ] {.text-smaller}
1207+ - use pronounceable names
1208+ - use searchable names
1209+ - [ "The longer the scope of a function, the shorter its name should be." -- Robert C. Martin] {.text-smaller}
1210+ - avoid encodings
1211+ - [ ` intNumberOfDays = 0 ` ] {.text-smaller}
1212+ - don't pun or use humor, be professional
1213+
1214+ :::::::::
1215+ ::::::::: {.column width="40%"}
1216+ ![ ] ( figures/publicdomainvectors/hand-with-bottle.svg ) {height=300}
1217+
1218+ :::::::::
1219+ ::::::::::::
1220+
1221+ ## names for classes, functions
1222+
1223+ :::::::::::: {.columns .mt-3}
1224+ ::::::::: {.column width="50%"}
1225+ - a class is a model / blueprint of * something*
1226+ - the name should be a noun
1227+ - e.g., ` User ` , ` Activity `
1228+ - an object is an instance of a class
1229+ - still a noun
1230+ - e.g., ` user = User() `
1231+ :::::::::
1232+ ::::::::: {.column width="50%"}
1233+ - a function * does* something
1234+ - the name should contain a verb
1235+ - in imperative
1236+ - e.g., ` aggregate_activity `
1237+ - ~~ ` activity_aggregation ` ~~
1238+
1239+ :::::::::
1240+ ::::::::::::
1241+
1242+ ## clean code / functions [ @martin2009clean ]
1243+
1244+ :::::::::::: {.columns}
1245+ ::::::::: {.column width="70%"}
1246+ - "Functions should hardly ever be 20 lines long" [ @martin2009clean ]
1247+ - shorter functions are easier to understand
1248+ - do one thing (single responsibility principle)
1249+ - "The longer the scope of a function, the shorter its name should be." -- Robert C. Martin
1250+ - avoid using more than three arguments
1251+ - avoid using flags
1252+ - no side effects
1253+ - prefer exceptions to returning error codes
1254+ :::::::::
1255+ ::::::::: {.column width="30%"}
1256+ ![ ] ( figures/publicdomainvectors/cogwheel.svg ) {height=300}
1257+
1258+ :::::::::
1259+ ::::::::::::
1260+
1261+
1262+ ## clean code / comments [ @martin2009clean ]
1263+
1264+ :::::::::::: {.columns .column-gapless}
1265+ ::::::::: {.column width="60%"}
1266+ ** avoid**
1267+
1268+ - journal comments
1269+ - noise comments
1270+ - writing something that is already in the code
1271+ - closing brace comments
1272+ - separating comments
1273+
1274+ ** however, comments can be used if they help to understand the code**
1275+
1276+ - informative comments, that explain what is happening
1277+ - math, physics, domain-specific things
1278+ - (API) documentation with examples
1279+ :::::::::
1280+ ::::::::: {.column width="40%"}
1281+ ![ by Oliver Widder (Geek and Poke) [ CC  ; BY  ; 3.0] ( https://creativecommons.org/licenses/by/3.0/ )] ( figures/borrowed/geek_and_poke/good_comments.jpg ) {width=375}
1282+
1283+ :::::::::
1284+ ::::::::::::
1285+
11881286# references
11891287
11901288::: {#refs}
0 commit comments