root / RuPy / slides.html

Revision 81:803018bb60ec, 23.6 kB (checked in by Tarek Ziad?? <tarek@…>, 21 months ago)

more

Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
7<meta name="version" content="S5 1.1" />
8<title>RuPy'07</title>
9<style type="text/css">
10
11/*
12:Author: David Goodger
13:Contact: goodger@users.sourceforge.net
14:Date: $Date: 2005-12-18 01:56:14 +0100 (Sun, 18 Dec 2005) $
15:Revision: $Revision: 4224 $
16:Copyright: This stylesheet has been placed in the public domain.
17
18Default cascading style sheet for the HTML output of Docutils.
19
20See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
21customize this style sheet.
22*/
23
24/* used to remove borders from tables and images */
25.borderless, table.borderless td, table.borderless th {
26  border: 0 }
27
28table.borderless td, table.borderless th {
29  /* Override padding for "table.docutils td" with "! important".
30     The right padding separates the table cells. */
31  padding: 0 0.5em 0 0 ! important }
32
33.first {
34  /* Override more specific margin styles with "! important". */
35  margin-top: 0 ! important }
36
37.last, .with-subtitle {
38  margin-bottom: 0 ! important }
39
40.hidden {
41  display: none }
42
43a.toc-backref {
44  text-decoration: none ;
45  color: black }
46
47blockquote.epigraph {
48  margin: 2em 5em ; }
49
50dl.docutils dd {
51  margin-bottom: 0.5em }
52
53/* Uncomment (and remove this text!) to get bold-faced definition list terms
54dl.docutils dt {
55  font-weight: bold }
56*/
57
58div.abstract {
59  margin: 2em 5em }
60
61div.abstract p.topic-title {
62  font-weight: bold ;
63  text-align: center }
64
65div.admonition, div.attention, div.caution, div.danger, div.error,
66div.hint, div.important, div.note, div.tip, div.warning {
67  margin: 2em ;
68  border: medium outset ;
69  padding: 1em }
70
71div.admonition p.admonition-title, div.hint p.admonition-title,
72div.important p.admonition-title, div.note p.admonition-title,
73div.tip p.admonition-title {
74  font-weight: bold ;
75  font-family: sans-serif }
76
77div.attention p.admonition-title, div.caution p.admonition-title,
78div.danger p.admonition-title, div.error p.admonition-title,
79div.warning p.admonition-title {
80  color: red ;
81  font-weight: bold ;
82  font-family: sans-serif }
83
84/* Uncomment (and remove this text!) to get reduced vertical space in
85   compound paragraphs.
86div.compound .compound-first, div.compound .compound-middle {
87  margin-bottom: 0.5em }
88
89div.compound .compound-last, div.compound .compound-middle {
90  margin-top: 0.5em }
91*/
92
93div.dedication {
94  margin: 2em 5em ;
95  text-align: center ;
96  font-style: italic }
97
98div.dedication p.topic-title {
99  font-weight: bold ;
100  font-style: normal }
101
102div.figure {
103  margin-left: 2em ;
104  margin-right: 2em }
105
106div.footer, div.header {
107  clear: both;
108  font-size: smaller }
109
110div.line-block {
111  display: block ;
112  margin-top: 1em ;
113  margin-bottom: 1em }
114
115div.line-block div.line-block {
116  margin-top: 0 ;
117  margin-bottom: 0 ;
118  margin-left: 1.5em }
119
120div.sidebar {
121  margin-left: 1em ;
122  border: medium outset ;
123  padding: 1em ;
124  background-color: #ffffee ;
125  width: 40% ;
126  float: right ;
127  clear: right }
128
129div.sidebar p.rubric {
130  font-family: sans-serif ;
131  font-size: medium }
132
133div.system-messages {
134  margin: 5em }
135
136div.system-messages h1 {
137  color: red }
138
139div.system-message {
140  border: medium outset ;
141  padding: 1em }
142
143div.system-message p.system-message-title {
144  color: red ;
145  font-weight: bold }
146
147div.topic {
148  margin: 2em }
149
150h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
151h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
152  margin-top: 0.4em }
153
154h1.title {
155  text-align: center }
156
157h2.subtitle {
158  text-align: center }
159
160hr.docutils {
161  width: 75% }
162
163img.align-left {
164  clear: left }
165
166img.align-right {
167  clear: right }
168
169ol.simple, ul.simple {
170  margin-bottom: 1em }
171
172ol.arabic {
173  list-style: decimal }
174
175ol.loweralpha {
176  list-style: lower-alpha }
177
178ol.upperalpha {
179  list-style: upper-alpha }
180
181ol.lowerroman {
182  list-style: lower-roman }
183
184ol.upperroman {
185  list-style: upper-roman }
186
187p.attribution {
188  text-align: right ;
189  margin-left: 50% }
190
191p.caption {
192  font-style: italic }
193
194p.credits {
195  font-style: italic ;
196  font-size: smaller }
197
198p.label {
199  white-space: nowrap }
200
201p.rubric {
202  font-weight: bold ;
203  font-size: larger ;
204  color: maroon ;
205  text-align: center }
206
207p.sidebar-title {
208  font-family: sans-serif ;
209  font-weight: bold ;
210  font-size: larger }
211
212p.sidebar-subtitle {
213  font-family: sans-serif ;
214  font-weight: bold }
215
216p.topic-title {
217  font-weight: bold }
218
219pre.address {
220  margin-bottom: 0 ;
221  margin-top: 0 ;
222  font-family: serif ;
223  font-size: 100% }
224
225pre.literal-block, pre.doctest-block {
226  margin-left: 2em ;
227  margin-right: 2em ;
228  background-color: #eeeeee }
229
230span.classifier {
231  font-family: sans-serif ;
232  font-style: oblique }
233
234span.classifier-delimiter {
235  font-family: sans-serif ;
236  font-weight: bold }
237
238span.interpreted {
239  font-family: sans-serif }
240
241span.option {
242  white-space: nowrap }
243
244span.pre {
245  white-space: pre }
246
247span.problematic {
248  color: red }
249
250span.section-subtitle {
251  /* font-size relative to parent (h1..h6 element) */
252  font-size: 80% }
253
254table.citation {
255  border-left: solid 1px gray;
256  margin-left: 1px }
257
258table.docinfo {
259  margin: 2em 4em }
260
261table.docutils {
262  margin-top: 0.5em ;
263  margin-bottom: 0.5em }
264
265table.footnote {
266  border-left: solid 1px black;
267  margin-left: 1px }
268
269table.docutils td, table.docutils th,
270table.docinfo td, table.docinfo th {
271  padding-left: 0.5em ;
272  padding-right: 0.5em ;
273  vertical-align: top }
274
275table.docutils th.field-name, table.docinfo th.docinfo-name {
276  font-weight: bold ;
277  text-align: left ;
278  white-space: nowrap ;
279  padding-left: 0 }
280
281h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
282h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
283  font-size: 100% }
284
285tt.docutils {
286  background-color: #eeeeee }
287
288ul.auto-toc {
289  list-style-type: none }
290
291</style>
292<!-- configuration parameters -->
293<meta name="defaultView" content="slideshow" />
294<meta name="controlVis" content="hidden" />
295<!-- style sheet links -->
296<script src="ui/default/slides.js" type="text/javascript"></script>
297<link rel="stylesheet" href="ui/default/slides.css"
298      type="text/css" media="projection" id="slideProj" />
299<link rel="stylesheet" href="ui/default/outline.css"
300      type="text/css" media="screen" id="outlineStyle" />
301<link rel="stylesheet" href="ui/default/print.css"
302      type="text/css" media="print" id="slidePrint" />
303<link rel="stylesheet" href="ui/default/opera.css"
304      type="text/css" media="projection" id="operaFix" />
305
306<style type="text/css">
307#currentSlide {display: none;}
308</style>
309</head>
310<body>
311<div class="layout">
312<div id="controls"></div>
313<div id="currentSlide"></div>
314<div id="header">
315
316</div>
317<div id="footer">
318<h1>RuPy'07</h1>
319
320</div>
321</div>
322<div class="presentation">
323<div class="slide" id="slide0">
324<h1 class="title">RuPy'07</h1>
325<p>Agile documentation in Python projects</p>
326<table class="docutils field-list" frame="void" rules="none">
327<col class="field-name" />
328<col class="field-body" />
329<tbody valign="top">
330<tr class="field"><th class="field-name">Author:</th><td class="field-body">Tarek Ziadé &lt;<a class="reference" href="mailto:tarek&#64;ziade.org">tarek&#64;ziade.org</a>&gt;</td>
331</tr>
332<tr class="field"><th class="field-name">Date:</th><td class="field-body">$Date: 2007-02-21$</td>
333</tr>
334<tr class="field"><th class="field-name">License:</th><td class="field-body">CC-By-SA 2 license</td>
335</tr>
336</tbody>
337</table>
338<!-- contents: -->
339
340</div>
341<div class="slide" id="how-am-i">
342<h1>How am I ?</h1>
343<ul class="simple">
344<li>Python developer since 2000</li>
345<li>Core developer in Nuxeo CPS (Zope) for 3 years</li>
346<li>Involved in Zope sprints</li>
347<li>Author of<ul>
348<li>a French book &quot;Programmation Python&quot; (Eyrolles, 2006)</li>
349<li>another one coming up this summer</li>
350<li>articles in magazines</li>
351</ul>
352</li>
353<li>Creator of AFPY (french speaking PUG)</li>
354<li>CTO at Emencia, for a Python e-commerce framework</li>
355</ul>
356</div>
357<div class="slide" id="what-are-the-goals-of-this-presentation">
358<h1>What are the goals of this presentation ?</h1>
359<p>The main goal is to understand how Agile documentation works in Python,
360through:</p>
361<ul class="simple">
362<li>Understanding how Test-Driven Development works in Python</li>
363<li>Discovering reStructuredText and doctests</li>
364<li>Understanding how Document-Driven Developement works</li>
365<li>Learning a few patterns</li>
366</ul>
367</div>
368<div class="slide" id="id1">
369<h1>What are the goals of this presentation ?</h1>
370<p>My secret goal is to come to RuPy to see how Ruby works...</p>
371</div>
372<div class="slide" id="the-plan">
373<h1>The plan</h1>
374<ul class="simple">
375<li><strong>A few definitions</strong></li>
376<li><cite>Part 1: doing TDD in Python</cite></li>
377<li><cite>Part 2: writing documents in reST</cite></li>
378<li><cite>Part 3: writing doctests</cite></li>
379<li><cite>Part 4: doing DDD in Python</cite></li>
380</ul>
381</div>
382<div class="slide" id="a-few-definitions">
383<h1>A few definitions</h1>
384<p>What kind of documentation are we talking about ?</p>
385</div>
386<div class="slide" id="id2">
387<h1>A few definitions</h1>
388<p>Technical documentation that helps to understand how a codebase
389works and how it can be used. This can be:</p>
390<ul class="simple">
391<li>a document describing a package <a class="footnote-reference" href="#id5" id="id3" name="id3">[1]</a>, a module <a class="footnote-reference" href="#id5" id="id4" name="id4">[1]</a> or a
392serie of package</li>
393<li>a glossary</li>
394<li>a tutorial</li>
395<li>a recipe</li>
396</ul>
397<table class="docutils footnote" frame="void" id="id5" rules="none">
398<colgroup><col class="label" /><col /></colgroup>
399<tbody valign="top">
400<tr><td class="label"><a name="id5">[1]</a></td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> Python folders and files</td></tr>
401</tbody>
402</table>
403</div>
404<div class="slide" id="id6">
405<h1>A few definitions</h1>
406<p>What <strong>Agile</strong> means ?</p>
407</div>
408<div class="slide" id="id7">
409<h1>A few definitions</h1>
410<p><strong>A lightweight process to stay reactive to frequent changes</strong></p>
411<ul class="simple">
412<li>Comes from the Agile Manifesto<ul>
413<li><a class="reference" href="http://agilemanifesto.org/">http://agilemanifesto.org/</a> <a class="footnote-reference" href="#id9" id="id8" name="id8">[2]</a></li>
414<li>created by members of the GoF (Beck, etc.) and others</li>
415<li>XP is one popular agile method</li>
416</ul>
417</li>
418</ul>
419<table class="docutils footnote" frame="void" id="id9" rules="none">
420<colgroup><col class="label" /><col /></colgroup>
421<tbody valign="top">
422<tr><td class="label"><a class="fn-backref" href="#id8" name="id9">[2]</a></td><td>The website looks a bit like some sect site but it's a good sect</td></tr>
423</tbody>
424</table>
425</div>
426<div class="slide" id="id10">
427<h1>A few definitions</h1>
428<p>Agile principles can be applied to any repeating process:</p>
429<ul class="simple">
430<li>coding</li>
431<li>documenting</li>
432<li>lawn-mowing</li>
433<li>etc.</li>
434</ul>
435</div>
436<div class="slide" id="id11">
437<h1>The plan</h1>
438<ul class="simple">
439<li><cite>A few definitions</cite></li>
440<li><strong>Part 1: doing TDD in Python</strong></li>
441<li><cite>Part 2: writing documents in reST</cite></li>
442<li><cite>Part 3: writing doctests</cite></li>
443<li><cite>Part 4: doing DDD in Python</cite></li>
444</ul>
445</div>
446<div class="slide" id="part-1">
447<h1>Part 1</h1>
448<p><strong>Doing TDD in Python</strong></p>
449<p>This part is composed of:</p>
450<ul class="simple">
451<li><strong>The TDD principles</strong></li>
452<li><cite>How to write tests in Python</cite></li>
453<li><cite>How to organise tests in a Python project</cite></li>
454</ul>
455</div>
456<div class="slide" id="tdd-principles">
457<h1>TDD Principles</h1>
458<ul class="simple">
459<li>Each function or method can have one or several sample use case</li>
460<li>A sample use case == a test</li>
461</ul>
462</div>
463<div class="slide" id="id12">
464<h1>TDD Principles</h1>
465<p>Example:</p>
466<pre class="literal-block">
467&gt;&gt;&gt; def division(a, b):
468...     return a / b
469</pre>
470<p>Let's test it !</p>
471<pre class="literal-block">
472&gt;&gt;&gt; def test_division():
473...     if division(4, 2) == 2:
474...         return 'OK'
475...     else:
476...         return 'SHUT DOWN THE COMPUTER NOW !'
477&gt;&gt;&gt; test_division()
478'OK'
479</pre>
480</div>
481<div class="slide" id="id13">
482<h1>TDD Principles</h1>
483<p>Each use case tests one aspect of the code</p>
484<p>Let's try this one:</p>
485<pre class="literal-block">
486&gt;&gt;&gt; def test_division2():
487...     if division(4, 0) == 0:
488...         return 'OK'
489...     else:
490...         return 'I WANT ZERO'
491&gt;&gt;&gt; test_division2()
492Traceback (most recent call last):
493...
494ZeroDivisionError: integer division or modulo by zero
495</pre>
496</div>
497<div class="slide" id="id14">
498<h1>TDD Principles</h1>
499<p>The function fails, let's change it:</p>
500<pre class="literal-block">
501&gt;&gt;&gt; def division(a, b):
502...     if b == 0:
503...         return 0
504...     return a / b
505</pre>
506<p>and rerun the test:</p>
507<pre class="literal-block">
508&gt;&gt;&gt; test_division2()
509'OK'
510</pre>
511</div>
512<div class="slide" id="id15">
513<h1>TDD Principles</h1>
514<ul class="simple">
515<li>The tests now validate several use cases for the function</li>
516<li>Running all those tests == test suite</li>
517<li>The function is now tighted to its test suite</li>
518</ul>
519</div>
520<div class="slide" id="id16">
521<h1>TDD Principles</h1>
522<p>Let's write the tests before the code:</p>
523<pre class="literal-block">
524&gt;&gt;&gt; def test_average():
525...     if average(1, 2, 3) == 2:
526...         return 'OK'
527...     else:
528...         return 'Houston we have a problem'
529&gt;&gt;&gt; test_average()
530Traceback (most recent call last):
531...
532NameError: global name 'average' is not defined
533</pre>
534</div>
535<div class="slide" id="id17">
536<h1>TDD Principles</h1>
537<p>Now let's code <cite>average</cite>:</p>
538<pre class="literal-block">
539