.. -*- coding: utf-8 -*- .. role:: sref(numref) .. role:: xref(numref) .. Copyright (C) 2019, Wolfgang Scherer, .. This file is part of Development. .. Permission is granted to copy, distribute and/or modify this document .. under the terms of the GNU Free Documentation License, Version 1.3 .. or any later version published by the Free Software Foundation; .. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. .. A copy of the license is included in the section entitled "GNU .. Free Documentation License". .. inline comments (with du_comment_role) .. role:: rem(comment) .. role:: html(raw) :format: html .. role:: shx(code) :language: sh .. >>CODD Introduction ================================================== :rem:`|||:sec:|||`\ Introduction ================================================== Software development is as old as human history, it has given us many a religious belief system, used to control human brains, ultimately eliciting desired behavior in the attached human body. .. >>CODD Chapter ================================================== :rem:`|||:sec:|||`\ Software development model ================================================== .. uml:: @startuml state "Design" as D state "Design Review" as RD state "Implementation" as I state "Implementation Review" as RI state "Refactoring Review" as RR [*] --> D D --> RD : finished RD --> D : rejected RD --> I : approved I --> RR: problem RR --> D : re-design RR --> I : documentation only\n"known bug" I --> RI: finished RI --> RR : rejected RI --> [*] : approved @enduml ================================================== :rem:`|||:sec:|||`\ Control Structures ================================================== All control structures can be reduced to a conditional jump (see `Control Structures`_ (German)). The unconditional while loop (endless loop) with a break before the repetition can be used to simulate complex free form `case / when`_ structures that do not fit the if / elseif cascade nicely. With a conventional while loop, initialization/continuation code:is somethimes duplicated (see :xref:`lst:duplicated initcont code`). .. _`lst:duplicated initcont code`: .. code-block:: python :caption: duplicated init/cont code :linenos: ch = get_char() while ch != EOF: print(ch) ch = get_char() :xref:`lst:single instance of initcont code` shows, how this duplication can be avoided. .. _`lst:single instance of initcont code`: .. code-block:: python :caption: single instance of init/cont code :linenos: while True: ch = get_char() if ch == EOF: break print(ch) Another common problem is found in shell scripts, when it is necessary to determine whether one or more files actually exist (see :xref:`lst:file existence check`). .. _`lst:file existence check`: .. code-block:: sh :caption: file existence check :linenos: # clear first_readable #a0 :; first_readable= # while (for each _file in screenlog.?) is (do) #a0 for _file in screenlog.?; do # if (_file is **not** readable?) then (yes) #a0 test -r "${_file}" || break #a0 # endif #a0 # set first_readable = "${_file}" #a0 :;; first_readable="${_file}" break #a0 done #a0 # if (first_readable is empty?) then (yes) #a0 test -z "${first_readable}" && ... # endif #a0 :xref:`fig:activitiy diagram for file existence check` shows the logic behind the file existence check. .. _`fig:activitiy diagram for file existence check`: .. uml:: :caption: activitiy diagram for file existence check @startuml /' a0 '/ skinparam padding 1 start :clear first_readable; while (for each _file in screenlog.?) is (do) if (_file is **not** readable?) then (yes) break endif :set first_readable = "${_file}"; break endwhile if (first_readable is empty?) then (yes) endif stop @enduml .. _`Control Structures`: http://sw-amt.ws/~kurs/basics/control-structures/html/ctrl-struct_tf.html .. _`Case / When`: http://sw-amt.ws/~kurs/basics/control-structures/html/node19.html .. >>CODD Conclusion .. >>CODD Appendix A .. \|:here:| .. >>CODD Notes .. ================================================== .. :rem:`|||:sec:|||`\ Footnotes .. ================================================== :html:`
` .. \[#] .. \|:info:| put local references here .. \|:info:| put local definitions here .. include:: doc_defs.inc .. include:: abbrev_defs.inc .. include:: doc_defs_combined.inc .. .. \||<-snap->|| doc_standalone .. include:: doc/doc_defs_secret.inc .. \||<-snap->|| doc_standalone .. \||<-snap->|| not_doc_standalone .. include:: doc_defs_secret.inc .. \||<-snap->|| not_doc_standalone .. _`Wolfgang Scherer`: wolfgang.scherer@gmx.de