Skip to content

Commit f456cd3

Browse files
committed
Start using new goodpractice environment.
1 parent 27a4c32 commit f456cd3

File tree

8 files changed

+20
-15
lines changed

8 files changed

+20
-15
lines changed

talk/basicconcepts/assert.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
\begin{frame}[fragile]
3939
\frametitlecpp[98]{Assertions}
40-
\begin{block}{Good practices}
40+
\begin{goodpractice}{Assert}
4141
\begin{itemize}
4242
\item Assertions are mostly for developers and debugging
4343
\item Use them to check important invariants of your program
@@ -48,7 +48,7 @@
4848
\item Decide if you want to disable them when you release code
4949
\end{itemize}
5050
\end{itemize}
51-
\end{block}
51+
\end{goodpractice}
5252
\begin{exampleblock}{Disabling assertions}
5353
\small
5454
Compile a program with NDEBUG defined:\\

talk/basicconcepts/functions.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@
216216
\begin{frame}[fragile]
217217
\frametitlecpp[98]{Functions: good practices}
218218
\begin{onlyenv}<1>
219-
\begin{block}{Ensure good readability/maintainability:}
219+
\begin{goodpractice}{Write readable functions}
220220
\begin{itemize}
221221
\item Keep functions short
222222
\item Do one logical thing (single-responsibility principle)
223223
\item Use expressive names
224224
\item Document non-trivial functions
225225
\end{itemize}
226-
\end{block}
226+
\end{goodpractice}
227227
\begin{exampleblock}{Example: Good}
228228
\begin{cppcode*}{gobble=2}
229229
/// Count number of dilepton events in data.

talk/basicconcepts/references.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
\end{itemize}
4343
\end{block}
4444
\pause
45-
\begin{alertblock}{Good practice}
45+
\begin{goodpractice}{References}
4646
\begin{itemize}
4747
\item Always use references when you can
4848
\item Consider that a reference will be modified
4949
\item Use constness when it's not the case
5050
\end{itemize}
51-
\end{alertblock}
51+
\end{goodpractice}
5252
\end{frame}

talk/basicconcepts/scopesnamespaces.tex

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@
3636
\begin{itemize}
3737
\item Variables are (statically) allocated when defined
3838
\item Variables are freed at the end of a scope
39-
\item Good practice: initialise variables when allocating them!
4039
\end{itemize}
4140
\end{block}
41+
\begin{goodpractice}{Initialisation}
42+
\begin{itemize}
43+
\item Initialise variables when allocating them!
44+
\item This prevents bugs reading uninitialised memory
45+
\end{itemize}
46+
\end{goodpractice}
4247
\begin{multicols}{2}
4348
\begin{overprint}[\columnwidth]
4449
\onslide<1>

talk/concurrency/mutexes.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@
112112

113113
\begin{frame}[fragile]
114114
\frametitlecpp[17]{Mutexes and Locks}
115-
\begin{block}{Good practice}
115+
\begin{goodpractice}{Locking}
116116
\begin{itemize}
117117
\item Generally, use \mintinline{cpp}{std::scoped_lock}. Before \cpp17 use \mintinline{cpp}{std::lock_guard}.
118118
\item Hold as short as possible, consider wrapping critical section in block statement \mintinline{cpp}|{ }|
119119
\item Only if manual control needed, use \mintinline{cpp}{std::unique_lock}
120120
\end{itemize}
121-
\end{block}
121+
\end{goodpractice}
122122
\begin{exampleblock}{}
123123
\begin{cppcode*}{gobble=2}
124124
void function(...) {

talk/expert/sfinae.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@
278278
}
279279
\end{cppcode*}
280280
\end{block}
281-
\begin{exampleblock}{Best practice}
281+
\begin{goodpractice}{SFINAE vs.\ if constexpr}
282282
\begin{itemize}
283283
\item \mintinline{cpp}{if constexpr} can replace SFINAE in many places.
284284
\item It is usually more readable as well. Use it if you can.
285285
\end{itemize}
286-
\end{exampleblock}
286+
\end{goodpractice}
287287
\end{frame}

talk/morelanguage/initialization.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
\begin{frame}[fragile]
149149
\frametitlecpp[11]{Initialization}
150-
\begin{exampleblock}{Best practices}
150+
\begin{goodpractice}{Initialization}
151151
\begin{itemize}
152152
\item In generic code, for a generic type \mintinline{cpp}{T}:
153153
\begin{itemize}
@@ -166,7 +166,7 @@
166166
\end{itemize}
167167
\item Aggregates are very flexible. If your class does not need special initialization, make it an aggregate (rule of zero)
168168
\end{itemize}
169-
\end{exampleblock}
169+
\end{goodpractice}
170170
\end{frame}
171171

172172
\begin{frame}[fragile]

talk/objectorientation/advancedoo.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,11 @@
359359
p->draw();
360360
delete p; // dynamic dispatch to right destructor
361361
\end{cppcode}
362-
\begin{exampleblock}{Best practice}
362+
\begin{goodpractice}{Virtual destructors}
363363
\begin{itemize}
364364
\item If you expect users to inherit from your class and override methods (i.e.\ use your class polymorphically), declare its destructor \mintinline{cpp}{virtual}
365365
\end{itemize}
366-
\end{exampleblock}
366+
\end{goodpractice}
367367
\end{frame}
368368

369369
\begin{frame}[fragile]

0 commit comments

Comments
 (0)