From fe0a52b32f2f1765af2b6132d486043ff8e013a4 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Sat, 13 May 2017 17:08:56 +0200 Subject: [PATCH] Canging to @annotations for slide generation --- Doc/Sd1/objectsClasses.xml | 186 +++++++++++++++++-------------------- Doc/Tdoc/general.xml | 6 +- Doc/Tdoc/software.xml | 6 +- 3 files changed, 86 insertions(+), 112 deletions(-) diff --git a/Doc/Sd1/objectsClasses.xml b/Doc/Sd1/objectsClasses.xml index 24544ee42..c25447f2d 100644 --- a/Doc/Sd1/objectsClasses.xml +++ b/Doc/Sd1/objectsClasses.xml @@ -9,69 +9,76 @@ xmlns:db="http://docbook.org/ns/docbook"> <title>Objects and Classes</title> - <section xml:id="classintro"> + <section annotations="slide" xml:id="classintro"> <title>Objects and classes</title> - <annotation role="slide"> - <para>This section and its children will appear as slides as - well.</para> - </annotation> - <para>Defining classes and creating objects.</para> <section xml:id="objectsClassesBasics"> <title>Classes in OO languages</title> - <itemizedlist> - <listitem> - <para>Blueprints for objects</para> - </listitem> + <informalfigure> + <para>In object oriented languages classes:</para> - <listitem> - <para>Attributes and methods.</para> - </listitem> - </itemizedlist> - </section> + <itemizedlist> + <listitem> + <para>are blueprints for objects</para> + </listitem> - <section xml:id="classVsInstance"> - <title>Classes and instances</title> + <listitem> + <para>contain attributes and methods.</para> + </listitem> - <mediaobject> - <imageobject> - <imagedata fileref="Ref/Fig/class.svg"/> - </imageobject> - </mediaobject> - </section> + <listitem> + <para>may hide their implementation</para> + </listitem> - <section xml:id="sectDefineBicycle"> - <title>Defining a class <classname>Bicycle</classname></title> + <listitem> + <para>allow for tailored access</para> + </listitem> + </itemizedlist> + </informalfigure> - <programlisting language="java">public class Bicycle <co - linkends="calloutClassBicycle-1" xml:id="calloutClassBicycle-1-co"/> { + <figure xml:id="figClassVsInstance"> + <title>Classes and instances</title> + + <mediaobject> + <imageobject> + <imagedata fileref="Ref/Fig/class.svg"/> + </imageobject> + </mediaobject> + </figure> + + <figure xml:id="figClassBicycle"> + <title>A class Bicycle</title> + + <programlisting language="java">public class Bicycle <co + linkends="calloutClassBicycle-1" xml:id="calloutClassBicycle-1-co"/> { float speed; <co linkends="calloutClassBicycle-2" - xml:id="calloutClassBicycle-2-co"/> // km per hour + xml:id="calloutClassBicycle-2-co"/> // km per hour void accelerate() <co linkends="calloutClassBicycle-3" - xml:id="calloutClassBicycle-3-co"/> { + xml:id="calloutClassBicycle-3-co"/> { speed += 2; }</programlisting> - <calloutlist> - <callout arearefs="calloutClassBicycle-1-co" - xml:id="calloutClassBicycle-1"> - <para>Defining a class Bicycle</para> - </callout> - - <callout arearefs="calloutClassBicycle-2-co" - xml:id="calloutClassBicycle-2"> - <para>An attribute <property>speed</property>.</para> - </callout> - - <callout arearefs="calloutClassBicycle-3-co" - xml:id="calloutClassBicycle-3"> - <para>A method <methodname>accelerate()</methodname>.</para> - </callout> - </calloutlist> + <calloutlist> + <callout arearefs="calloutClassBicycle-1-co" + xml:id="calloutClassBicycle-1"> + <para>Defining a class Bicycle</para> + </callout> + + <callout arearefs="calloutClassBicycle-2-co" + xml:id="calloutClassBicycle-2"> + <para>An attribute <property>speed</property>.</para> + </callout> + + <callout arearefs="calloutClassBicycle-3-co" + xml:id="calloutClassBicycle-3"> + <para>A method <methodname>accelerate()</methodname>.</para> + </callout> + </calloutlist> + </figure> </section> </section> @@ -3915,8 +3922,16 @@ System.out.println(factorial(3));</programlisting> fashion:</para> <informaltable border="1"> + <colgroup width="4%"/> + + <colgroup width="3%"/> + + <colgroup width="28%"/> + + <colgroup width="65%"/> + <tr> - <td><inlineequation> + <td rowspan="4" valign="top"><inlineequation> <m:math display="inline"> <m:mrow> <m:mi>4</m:mi> @@ -3960,12 +3975,10 @@ System.out.println(factorial(3));</programlisting> </m:math> </inlineequation></td> - <td>Recursion 4 - > 3</td> + <td>Recursion 4 -> 3</td> </tr> <tr> - <td/> - <td><inlineequation> <m:math display="inline"> <m:mo>=</m:mo> @@ -4008,8 +4021,6 @@ System.out.println(factorial(3));</programlisting> </tr> <tr> - <td/> - <td><inlineequation> <m:math display="inline"> <m:mo>=</m:mo> @@ -4056,8 +4067,6 @@ System.out.println(factorial(3));</programlisting> </tr> <tr> - <td/> - <td><inlineequation> <m:math display="inline"> <m:mo>=</m:mo> @@ -4104,42 +4113,6 @@ System.out.println(factorial(3));</programlisting> </m:math> </inlineequation></td> - <td>Recursion 1 -> 0</td> - </tr> - - <tr> - <td/> - - <td><inlineequation> - <m:math display="inline"> - <m:mo>=</m:mo> - </m:math> - </inlineequation></td> - - <td><inlineequation> - <m:math display="inline"> - <m:mrow> - <m:mi>4</m:mi> - - <m:mo>×</m:mo> - - <m:mi>3</m:mi> - - <m:mo>×</m:mo> - - <m:mi>2</m:mi> - - <m:mo>×</m:mo> - - <m:mi>1</m:mi> - - <m:mo>×</m:mo> - - <m:mi>1</m:mi> - </m:mrow> - </m:math> - </inlineequation></td> - <td>Termination condition <inlineequation> <m:math display="inline"> <m:mrow> @@ -4179,6 +4152,14 @@ System.out.println(factorial(3));</programlisting> } else { return n * factorialRecurse(n - 1); // Reducing step: n! = n * (n - 1)! }</programlisting> + + <para>If you fancy <quote>compact</quote> code you may as well + write.</para> + + <programlisting language="java"> static public long factorialRecurse(int n) { return 0 == n ? 1: n * f(n - 1);}</programlisting> + + <para>Beware: The latter sacrifies both readability and the + ability to debug for brevity. Your mileage may vary.</para> </answer> </qandaentry> </qandadiv> @@ -4413,8 +4394,8 @@ System.out.println(factorial(3));</programlisting> </m:math> </inlineequation>.</para> - <para>These are values from the left and right edge of - <xref linkend="sd1FigPascalTriangle"/>.</para> + <para>NB: These values show up along the left and right + edge in <xref linkend="sd1FigPascalTriangle"/>.</para> </glossdef> </glossentry> </glosslist> @@ -4441,11 +4422,12 @@ System.out.println(factorial(3));</programlisting> point.</para> <tip> - <para>Measuring method execution times is achieved by - using either <link + <para>The standard methods <link xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#currentTimeMillis--">currentTimeMillis()</link> - or <link - xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--">nanoTime</link>. + and <link + xlink:href="https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--">nanoTime</link> + allow for measuring method execution by means of + subtracting time stamp values prior and after execution. <quote xlink:href="https://www.mkyong.com/java/how-do-calculate-elapsed-execute-time-in-java">See How to calculate elapsed / execute time in @@ -4470,9 +4452,9 @@ System.out.println(factorial(3));</programlisting> <programlisting language="java"> public static long binomial(int n, int k) { - if (0 == k || n == k) { // End of recursion? + if (0 == k || n == k) { // End of recursion return 1; - } else { // Continue reducing: 0 < k < n holds true. + } else { // 0 < k < n holds true, so continue reducing return binomial(n - 1, k) + binomial(n - 1, k - 1); } }</programlisting> @@ -4545,14 +4527,14 @@ Ratio Recursive / Loop: 65554</programlisting></td> ~65000 times faster compared to the recursive approach.</para> <para>This is a typical result: Albeit providing elegant - solutions recursion in many situations is a <emphasis - role="bold">very bad</emphasis> idea with respect to - performance and thus strongly discouraged. There are however - situations where:</para> + solutions recursion based implementations frequently fails + when it comes to performance. Hence using recursion is often + strongly discouraged. There are however situations + where:</para> <orderedlist> <listitem> - <para>The performance penalty is small.</para> + <para>The performance penalty is acceptable.</para> </listitem> <listitem> diff --git a/Doc/Tdoc/general.xml b/Doc/Tdoc/general.xml index a88bee629..d1b6ddd76 100644 --- a/Doc/Tdoc/general.xml +++ b/Doc/Tdoc/general.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<chapter version="5.1" xml:id="tdocGeneral" +<chapter annotations="slide" version="5.1" xml:id="tdocGeneral" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes" @@ -11,10 +11,6 @@ xmlns:db="http://docbook.org/ns/docbook"> <title>Software independent considerations</title> - <annotation role="slide"> - <para>This section and its children will appear as slides as well.</para> - </annotation> - <para>In the next sections we will describe common building blocks of (technical) documents.</para> diff --git a/Doc/Tdoc/software.xml b/Doc/Tdoc/software.xml index 8fb9ebde5..f54e95eda 100644 --- a/Doc/Tdoc/software.xml +++ b/Doc/Tdoc/software.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<chapter version="5.0" xml:id="tdocSoftware" +<chapter annotations="slide" version="5.0" xml:id="tdocSoftware" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes" @@ -11,10 +11,6 @@ xmlns:db="http://docbook.org/ns/docbook"> <title>Software</title> - <annotation role="slide"> - <para>This section and its children will appear as slides as well.</para> - </annotation> - <section xml:id="tdocSoftFrontends"> <title>Frontends</title> -- GitLab