itCppCon20 - My Least Favorite Anti-Pattern (Conor Hoekstra)

preview_player
Показать описание
There is one anti-pattern that is pervasive – it shows up everywhere all the time: the ITM anti-pattern. This is my least favorite anti-pattern and avoiding it can lead to more readable, understandable and beautiful code. ITM stands for “Initialize Then Modify”. When Sean Parent says “no raw loops” – that is an application of avoiding ITM. When Ben Deane says “avoid the initialization declaration split” – that is an application of avoiding ITM. And when Jason Turner walks you through different code smells to avoid – a lot of them are examples of ITM. This talk will introduce the ITM anti-pattern, walk you through the story of my discovery of it and highlight / demonstrate how to avoid it.

---
Рекомендации по теме
Комментарии
Автор

Having the Python example towards the end (~44m in) is illustrative of a downside of the "no raw loops" mentality. Mutation and primitive loops tend not to differ language to language. However, the standard algorithm equivalent that fits into an expression that can be assigned to a const variable is very likely to be unintelligible to non-experts in the language. Declarative shorthand requires expertise far beyond imperative primitives common to all languages.

At my current employer, there is an expectation that a Python programmer should be able to diagnose and fix a critical bug in C++ code during on call rotations, and that is one of the reasons that the STL is largely forbidden. I tend to get frustrated with the restriction but seeing the reverse (advanced Python code that I can't grok) gives me a bit more empathy in the rationale.

bushidocodes