forked from psteinb/TDD_in_Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
457 lines (374 loc) · 16.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test-Driven Development - A C++ focused introduction</title>
<meta name="description" content="Tests first, make fail, make pass and refactor">
<meta name="author" content="Peter Steinbach" >
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/sky.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<!-- ALL SLIDES GO HERE -->
<!-- Each section element contains an individual slide -->
<section>
<h1>Test-Driven Development<br>in C++</h1>
<p><br></p>
<p>Dresden, Nov 13, 2014<br>
<a href="mailto:[email protected]">Peter Steinbach</a><br>
<a href="http://www.scionics.de">Scionics Computer Innovation GmbH</a><br>
</p>
</section>
<section>
<h2>Disclaimer</h2>
<p style="text-align: left;">This work is licensed under a<br> <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0<br> International License</a>.</p>
<div style="position: absolute; top: 20%; right: 10%; max-width: 80%;">
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/" target="_blank"><img width="176" alt="Creative Commons License" src="local/cc-by.png" /></a>
</div>
<p style="text-align: left;"><br>
All material contained in the slides are linked to their source if not produced by the author. If you find intellectual property is not attributed to your satisfaction, feel free to contact <a href="mailto:[email protected]">me</a>.<br><br>
For feedback, forks, discussions and contributions, go to
<center>
<a href="https://github.com/psteinb/TDD_in_Cpp">github.com/psteinb/TDD_in_cpp</a>.
</center>
</p>
</section>
<section>
<section>
<h1>How people code</h1>
</section>
<section>
<h2><b>First</b></h2>
<a href="http://commons.wikimedia.org/wiki/File:Pictofigo_-_Idea.png" target="_blank">
<img style="max-width: 50%" src="local/Pictofigo_-_Idea.png" alt="http://commons.wikimedia.org/wiki/File:Pictofigo_-_Idea.png">
</a>
<h3>Idea(s)</h3>
</section>
<section>
<h2><b>Second</b></h2>
<a href="http://www.jeffreydev.com/the-developer-title/" target="_blank">
<img style="max-width: 50%" src="local/developer.jpg" alt="www.jeffreydev.com/the-developer-title">
</a>
<h3>Coffee & Code</h3>
</section>
<section>
<h2><b>Third</b></h2>
<a href="http://en.wikipedia.org/wiki/STS-115" target="_blank">
<img width="40%" style="max-width: 40%" src="local/ShuttleAtlantis_launch.jpg" alt="en.wikipedia.org/wiki/STS-115">
</a>
<h3>Launch To Mars</h3>
</section>
<section>
<h2><b>Validate</b></h2>
<a href="http://en.wikipedia.org/wiki/Moon" target="_blank">
<img width="50%" style="max-width: 60%" src="local/Full_Moon_Luc_Viatour.jpg" alt="http://en.wikipedia.org/wiki/Moon">
</a>
<h3>Unexpected Result!</h3>
</section>
<section data-background="local/297b.jpg">
<!-- FIXME: not very flexible -->
<div style="position: absolute; top: -350px;">
<h1><font color="white"><b>Compile and run?</b></font></h1>
</div>
</section>
<section>
<div style="position: absolute; top: -50px;">
<h2>Build and Fix Software Model</h2>
<figure>
<a href="http://www.cc.gatech.edu/computing/SW_Eng/people/Faculty/Colin.Potts/Courses/3302/1-08-mgt/index.htm" target="_blank">
<img height="500" style="max-width: 60%" src="local/img004.GIF" alt="Build and Fix">
</a>
<figcaption style="font-size: 70%;">from <a href="http://www.cc.gatech.edu/computing/SW_Eng/people/Faculty/Colin.Potts/Courses/3302/1-08-mgt/index.htm" target="_blank">Software Process Models</a> (Lecture by Colin Potts, Gerogia Tech, 1998)
</figcaption>
</figure>
</div>
</section>
</section>
<section>
<section>
<h1>Code in Science</h1>
<a href="http://blog.f1000research.com/2014/04/04/reproducibility-tweetchat-recap/" target="_blank">
<img width="496" style="max-width: 60%" src="local/reproducibility-small.jpg" alt="blog.f1000research.com">
</a>
<h2>Reproducibility?</h2>
</section>
<section>
<h3><b>Preclinical Cancer Research</b></h3>
<figure>
<img style="max-width: 100%" src="local/nature_drug_development.png" alt="Nature Comment">
<figcaption>from <a href="http://www.nature.com/nature/journal/v483/n7391/full/483531a.html" target="_blank">Nature 2012</a>
</figcaption>
</figure>
</section>
<section>
<h3><b>Preclinical Cancer Research</b></h3>
<figure >
<img style="max-width: 100%" src="local/donut.png" alt="Nature Comment">
<figcaption>from <a href="http://www.nature.com/nature/journal/v483/n7391/full/483531a.html" target="_blank">[doi:10.1038/483531a]</a>
</figcaption>
</figure>
</section>
<section>
<h2>Scientific Computing?</h2>
<figure>
<a href="http://reproducible-research.github.io/scipy-tutorial-2014/" target="_blank">
<img width="700" style="max-width: 90%" src="local/scipy2014_reproducible_research.svg" alt="SciPy2014">
</a>
<figcaption>
Scipy 2014: <a href="http://reproducible-research.github.io/scipy-tutorial-2014/" target="_blank">Reproducible Research</a>
</figcaption>
</figure>
</section>
<!-- <section> -->
<!-- <h2>Science!</h2> -->
<!-- <p> -->
<!-- <blockquote class="fragment" style="text-align: left;"> -->
<!-- “It is clear that scientific code is full of if-else blocks and ugly ... it's science!” -->
<!-- <footer style="font-size: 70%; text-align: right;"><cite>-- anonymous PI</cite></footer> -->
<!-- </blockquote> -->
<!-- <br> -->
<!-- <blockquote class="fragment" style="text-align: left;"> -->
<!-- “We don't need software engineering ... it's just plotting the data!” -->
<!-- <footer style="font-size: 70%; text-align: right;"><cite>-- anonymous PI</cite></footer> -->
<!-- </blockquote> -->
<!-- </p> -->
<!-- </section> -->
</section>
<section>
<section>
<h2>Test-Driven<br>Development</h2>
<figure>
<a href="http://www.amazon.com/Test-Driven-Development-By-Example/dp/0321146530" target="_blank">
<img height="400" style="max-width: 70%" src="local/71lpKZxrK6L.jpg" >
</a>
<a href="http://en.wikipedia.org/wiki/Kent_Beck" target="_blank">
<img style="max-width: 40%" src="local/EGRPH2571.jpg" >
</a>
<figcaption>
by Kent Beck (2002)
</figcaption>
</figure>
</section>
<section>
<h2>How?</h2>
<figure>
<a href="http://octoberclub.files.wordpress.com/2011/10/red-green-refactor.png" target="_blank">
<img width="700" style="max-width: 70%" src="local/red-green-refactor.png" ></a>
<figcaption>
by <a href="http://octoberclub.files.wordpress.com/2011/10/red-green-refactor.png" target="_blank">Nat Pryce</a>
</figcaption>
</figure>
</section>
</section>
<section>
<h1><b>Live Demo</b></h1>
<h3><br>Writing a vector with a norm!</h3>
</section>
<section>
<section>
<h2><b>Classical Approach</b></h2>
<div class="fragment" style="text-align: left;"><p><b>Unit Test</b><br>method to test smallest testable part of an application</p></div>
<div class="fragment" style="text-align: left;"><p><b>Test Suite</b><br>sequence of Unit Tests that validate the same entity</p></div>
<div class="fragment" style="text-align: left;"><p><b>Test Fixture</b><br>called before/after execution of unit test to setup or tear down test environment</p></div>
</section>
<!-- <section> -->
<!-- <h2><b>Classical Approach</b></h2> -->
<!-- <div class="fragment" style="text-align: left;"><p><b>Unit Test</b><br>method to test smallest testable part of an application</p></div> -->
<!-- <div class="fragment" style="text-align: left;"><p><b>Test Suite</b><br>sequence of Unit Tests that validate the same entity</p></div> -->
<!-- <div class="fragment" style="text-align: left;"><p><b>Test Fixture</b><br>called before/after execution of unit test to setup or tear down test environment</p></div> -->
<!-- </section> -->
<section>
<h2><b>What to test?</b></h2>
<h3>Let's play!</h3>
</section>
<section>
<h2><b>Test the Contract!</b></h2>
<p><br></p>
<blockquote class="fragment" style="text-align: center;">
<ul>
<li><b>pre-condition</b><br /> (type and content of input data)</li>
<li><b>service it provides</b><br /> (the responsibility it has)</li>
<li><b>post-condition</b><br /> (type and content of output data)</li>
</ul>
<p><br></p>
<footer style="font-size: 70%; text-align: right;"><cite>-- Thomas/Hunt, <i>The Pragmatic Programmer</i>, Addison-Wesley Professional, 1999</cite></footer>
</blockquote>
</section>
<section>
<h2><b>Exercise?</b></h2>
<h3><a href="http://cyber-dojo.org/" target="_blank" name="cyber-dojo.org">cyber-dojo.org</a></h3>
<figure>
<a href="http://cyber-dojo.org/" target="_blank">
<img style="max-width: 90%" src="local/cyber-dojo.png" >
</a>
</figure>
</section>
<section>
<div style="background-color: #E62F0A; width: 100%; height: 400%; position: absolute; top: -50%; left: 50%; z-index: -1; opacity: 0.45;">
</div>
<h2>Summary</h2>
<div style="width: 50%; display: inline-block; margin-right: 9%; vertical-align: top;">
<p style="text-align: right;; font-size: 120%"><br>
<ul style="line-height: 150%">
<li class="fragment">incremental design</li>
<li class="fragment">developer confidence</li>
<li class="fragment">less feature envy</li>
<li class="fragment">reproducibility included</li>
<li class="fragment">documentation included</li>
<li class="fragment">continuous integration</li>
<li class="fragment">...</li>
</ul><br><br>
</p>
</div>
<div class="fragment" style="background-color: #01BE4C; width: 100%; height: 400%; position: absolute; top: -50%; right: 50%; z-index: -1; opacity: 0.45;" >
</div>
<div style="width: 40%; display: inline-block;" >
<p style="text-align: left;"><br>
<ul style="line-height: 150%;">
<li class="fragment">code is <i>less bug</i> free</li>
<li class="fragment">human interaction?</li>
<li class="fragment"><i>dead code?</i></li>
<li class="fragment">can be misleading!</li>
<li class="fragment"><i>hinders good design</i></li>
<li class="fragment">...</li>
</ul>
<br><br>
</p>
</div>
<h3 class="fragment"><a href="#/10">Ongoing Discussion!</a></h3>
</section>
</section>
<section>
<section>
<h2>Tools</h2>
<figure>
<img style="max-width: 70%" src="local/tools.jpg">
<figcaption>from <a href="http://upload.wikimedia.org/wikipedia/commons/f/f4/20060513_toolbox.jpg" target="_blank">wikipedia</a></figcaption></figure>
</section>
<section>
<h2>Standard Libraries</h2>
<ul style="line-height: 150%;">
<li><a href="http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page" target="_blank">CppUnit</a> </li>
<li><a href="http://code.google.com/p/googletest/" target="_blank">GoogleTest</a> </li>
<li><a href="http://www.boost.org/doc/libs/1_57_0/libs/test/doc/html/index.html" target="_blank">Boost.Test</a> </li>
<li><a href="https://launchpad.net/aeryn" target="_blank">Aeryn</a> </li>
<li><a href="http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B" target="_blank">and many more ...</a></li>
</ul>
</section>
<section>
<h2>Standard xUnit Approach</h2>
<figure>
<a href="http://junit.sourceforge.net/doc/cookstour/cookstour.htm" target="_blank">
<img style="max-width: 100%" src="local/xUnit.gif"></a>
<figcaption>from <a href="http://junit.sourceforge.net/doc/cookstour/cookstour.htm" target="_blank">junit.sourceforge.net</a></figcaption></figure>
</section>
<section>
<h2>State-of-the-Art Libraries</h2>
<ul style="line-height: 150%;">
<li><a href="https://github.com/philsquared/Catch" target="_blank">Catch</a> (C++03)</li>
<li><a href="http://jimporter.github.io/mettle/" target="_blank">Mettle</a> (C++14)</li>
<li><a href="https://github.com/martinmoene/lest" target="_blank">lest</a> (C++11)</li>
<li><a href="http://banditcpp.org/" target="_blank">bandit</a> (C++11)</li>
</ul>
</section>
<section>
<h2>Meta-Programming</h2>
<p><br></p>
<i>Code Inlined</i>
<pre><code data-trim>
//test inside the code in C++11 or with BOOST_STATIC_ASSERT in C++03
std::static_assert( sizeof(small_t) < sizeof(large_t) );
</code></pre>
<p><br></p>
<i>Boost MPL Test Asserts</i>
<pre><code data-trim>
#include "boost/mpl/assert.hpp"
BOOST_MPL_ASSERT( sizeof(small_t) < sizeof(large_t) );
BOOST_MPL_ASSERT_MSG( sizeof(small_t) < sizeof(large_t) ,
MESSAGE_THAT_WILL_BE_PRINTED);
BOOST_MPL_ASSERT_NOT(( boost::is_same< small_t,large_t > ));
BOOST_MPL_ASSERT_RELATION( sizeof(small_t), <, sizeof(large_t) );
</code></pre>
</section>
</section>
<section>
<h2>Summary</h2>
<ul style="line-height: 150%; font-size: 120%">
<li class="fragment">real-world test-driven development has a learning curve</li>
<li class="fragment">creates confidence and reproducibility</li>
<li class="fragment">good software design step-by-step</li>
<li class="fragment">a lot of tools available</li>
<li class="fragment">no silver bullet!</li>
</ul>
</section>
<section>
<h2>Thank you for your attention!</h2>
<figure>
<a href="http://upload.wikimedia.org/wikipedia/commons/7/7e/Sleeping_students.jpg">
<img width="600" style="max-width: 60%" src="local/Sleeping_students.jpg" />
</a>
<figcaption>from <a href="http://upload.wikimedia.org/wikipedia/commons/7/7e/Sleeping_students.jpg" target="_blank">wikimedia.org</a>
</figcaption>
</figure>
</section>
<section>
<h2>Literature</h2>
<ul style="text-align: left;line-height: 150%;">
<li>Robert C. Martin, <em>Agile Software Development: Principles, Patterns and Practices.</em> Pearson Education, 2002 </li>
<li>Kent Beck, <em>Test-Driven Development by Example.</em> Addison-Wesley Longman, 2002</li>
<li>Overload Magazine, <a href="http://accu.org/index.php/journals/c340/" target="_blank">Issue 122</a></li>
<li>"<a href="http://www.levelofindirection.com/journal/2014/10/7/modern-c-testing.html" target="_blank">Modern C++ Testing</a>" by Phil Nash (author of catch)</li>
</ul>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
slideNumber: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>