Christopher James Hayward
4 years ago
11 changed files with 0 additions and 218 deletions
-
BINdocs/daily/2021-02-03.org.gpg
-
12docs/notes/computer-science.org
-
BINdocs/notes/computer-science.org.gpg
-
12docs/notes/finite-mathematics.org
-
BINdocs/notes/finite-mathematics.org.gpg
-
51docs/notes/literate-programming.org
-
BINdocs/notes/literate-programming.org.gpg
-
12docs/notes/systems-analysis-design.org
-
BINdocs/notes/systems-analysis-design.org.gpg
-
131docs/notes/thinking-in-cpp.org
-
BINdocs/notes/thinking-in-cpp.org.gpg
@ -1,12 +0,0 @@ |
|||
#+TITLE: Computer Science |
|||
#+AUTHOR: Christopher James Hayward |
|||
|
|||
#+ROAM_KEY: https://chrishayward.xyz/notes/computer-science/ |
|||
|
|||
#+HUGO_BASE_DIR: ~/.local/source/website |
|||
#+HUGO_AUTO_SET_LASTMOD: t |
|||
#+HUGO_SECTION: notes |
|||
|
|||
#+HUGO_DRAFT: true |
|||
|
|||
[fn:scneider-2012] Schneider, G. M., & Gerstring, J. (2012). Invitation to Computer Science (6th ed.). https://online.vitalsource.com/books/0176692193 |
@ -1,12 +0,0 @@ |
|||
#+TITLE: Finite Mathematics |
|||
#+AUTHOR: Christopher James Hayward |
|||
|
|||
#+ROAM_KEY: https://chrishayward.xyz/notes/finite-mathematics/ |
|||
|
|||
#+HUGO_BASE_DIR: ~/.local/source/website |
|||
#+HUGO_AUTO_SET_LASTMOD: t |
|||
#+HUGO_SECTION: notes |
|||
|
|||
#+HUGO_DRAFT: true |
|||
|
|||
[fn:barnett-2014] Barnett, R. A., Ziegler, M. R., & Byleen, K. E. (2014). Finite Mathematics for Business, Economics, Life Sciences and Social Sciences, Global Edition. Pearson Education Canada. https://online.vitalsource.com/books/9781269580786 |
@ -1,51 +0,0 @@ |
|||
#+TITLE: Literate Programming |
|||
#+AUTHOR: Christopher James Hayward |
|||
|
|||
#+ROAM_KEY: https://chrishayward.xyz/notes/literate-programming/ |
|||
|
|||
#+HUGO_BASE_DIR: ~/.local/source/website |
|||
#+HUGO_AUTO_SET_LASTMOD: t |
|||
#+HUGO_SECTION: notes |
|||
|
|||
+ Programming paradigm |
|||
+ Programs expressed in natural language with code snippets |
|||
+ Produces machine readable code and human readable documentation |
|||
|
|||
* Introduction |
|||
|
|||
Described in its introduction[fn:knuth-1984] as a |
|||
|
|||
#+begin_quote |
|||
Programming paradigm in which a computer program is given an explanation of its logic in a natural language, such as English, interspersed with snippets of macros and traditional source code, from which compilable source code can be generated. |
|||
#+end_quote |
|||
|
|||
Knuth describes a *practitioner* in the introduction of his 1984 paper[fn:knuth-1984] as |
|||
|
|||
#+begin_quote |
|||
An essayist concerned with exposition and excellence of style. Someone who carefully selects the name for each variable and describes their meaning. They will strive for a program that is comprehensible because concepts are introduced in a manner best for human understanding. |
|||
#+end_quote |
|||
|
|||
* Concept |
|||
|
|||
#+begin_example |
|||
_____ |
|||
| | -> Send to Boss |
|||
_____ | doc | -> Copy to Team |
|||
| | -> Weave -> |_____| -> Copy to Support |
|||
| org | _____ |
|||
|_____| -> Tangle -> | | -> Test on CI |
|||
| src | -> Copy to CDN |
|||
|_____| -> Send to Customer |
|||
#+end_example |
|||
|
|||
Illustrated above we see the process of *weaving* and *tangling* the literate source file, and how each of the produced components is handled respectively. |
|||
|
|||
| File | Description | |
|||
|------+------------------------------| |
|||
| org | Literate document / file | |
|||
| src | Machine readable source code | |
|||
| doc | Human readable documentation | |
|||
|
|||
* Resources |
|||
|
|||
[fn:knuth-1984] Knuth, D. E. (1984). Literate Programming. The Computer Journal, 27(2), 97–111. https://doi.org/10.1093/comjnl/27.2.97 |
@ -1,12 +0,0 @@ |
|||
#+TITLE: Systems Analysis & Design |
|||
#+AUTHOR: Christopher James Hayward |
|||
|
|||
#+ROAM_KEY: https://chrishayward.xyz/notes/systems-analysis-design/ |
|||
|
|||
#+HUGO_BASE_DIR: ~/.local/source/website |
|||
#+HUGO_AUTO_SET_LASTMOD: t |
|||
#+HUGO_SECTION: notes |
|||
|
|||
#+HUGO_DRAFT: true |
|||
|
|||
[fn:satzinger-2002] Satzinger, J. W., Jackson, R. B., & Burd, S. D. (2002). Systems Analysis and Design in a Changing World (2. ed). Course Technology. https://online.vitalsource.com/books/0176656766 |
@ -1,131 +0,0 @@ |
|||
#+TITLE: Thinking in C++ |
|||
#+AUTHOR: Christopher James Hayward |
|||
|
|||
#+ROAM_KEY: https://chrishayward.xyz/notes/thinking-in-cpp/ |
|||
|
|||
#+HUGO_BASE_DIR: ~/.local/source/website |
|||
#+HUGO_AUTO_SET_LASTMOD: t |
|||
#+HUGO_SECTION: notes |
|||
|
|||
* Coding Style |
|||
|
|||
*Eckel* justifies the decisions about the coding styles in the text[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
All the decisions about coding style in this book have been deliberately considered and made, sometimes over a period of years. |
|||
#+end_quote |
|||
|
|||
** General |
|||
|
|||
The coding style as described by *Eckel* is one that he came to after years of practice, and originates from Bjarne Stroustrup's style, the Author of =C++=[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
I use a particular coding style for the examples in this book. It was developed over a number of years, and was partially inspired by Bjarne Stroustrup's style in his original The C++ Programming Language. |
|||
#+end_quote |
|||
|
|||
*Eckel* goes on to declare that it's more important to keep a consistent style, than to try to determine which is superior[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Because C++ is a free-form programming language, you can continue to use whatever style you're comfortable with. That said, I will note that it is important to have a consistent formatting style within a project. |
|||
#+end_quote |
|||
|
|||
** File names |
|||
|
|||
*Eckel* describes the history of the naming conventions for =C/C++= files[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
In C, it has been traditional to name header files (containing declarations) with an extension of .h and implementation files (that cause storage to be allocated and code to be generated) with an extension of .c. |
|||
#+end_quote |
|||
|
|||
Depending on the type of operating system, some files had different extensions as well[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
DOS C++ vendors used extensions of hxx and cxx for header files and implementation files, respectively, or hpp and cpp. Later, someone figured out that the only reason you needed a different extension for a file was so the compiler could determine whether to compile it as a C or C++ file |
|||
#+end_quote |
|||
|
|||
| Name | Extension | Description | |
|||
|----------------+-----------+-----------------------------| |
|||
| Header | .h | Header files for C/C++ | |
|||
| Header | .hxx | Header file for C++ on DOS | |
|||
| Implementation | .c | Implementation file for C | |
|||
| Implementation | .cpp | Implementaiton file for C++ | |
|||
|
|||
** Begin and end comment tags |
|||
|
|||
Most of the code examples in the text book have comment tags at the beginning and end, which is part of a system used by *Eckel* to verify all of the code examples[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
A very important issue with this book is that all code that you see in the book must be verified to be correct (with at least one compiler). |
|||
#+end_quote |
|||
|
|||
*Eckel* further elaborates how each example has a custom ~makefile~ and some program information included in the tags[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Because ExtractCode.cpp also creates a makefile for each subdirectory, information about how a program is made and the command-line used to test it is also incorporated into the listings. |
|||
#+end_quote |
|||
|
|||
** Parentheses, braces, and indentation |
|||
|
|||
The section begins with, what is in my opinion, an accurate statement by *Eckel*, although not without irony[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Of course, everyone thinks their own style is the most rational. However, the style used here has a simple logic behind it, which will be presented here mixed in with ideas on why some of the other styles developed. |
|||
#+end_quote |
|||
|
|||
On addressing indentation[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Everyone seems to agree that code inside braces should be indented. |
|||
#+end_quote |
|||
|
|||
*Eckel* addresses braces in his coding style[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
... the opening brace should always go on the same line as the "precursor" (by which I mean "whatever the body is about: a class, function, object definition, if statement, etc."). This is a single, consistent rule I apply to all of the code I write, and it makes formatting much simpler. |
|||
#+end_quote |
|||
|
|||
** Identifier names |
|||
|
|||
*Eckel* explains the naming conventions of identifiers[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Those familiar with Java will notice that I have switched to using the standard Java style for all identifier names. However, I cannot be completely consistent here because identifiers in the Standard C and C++ libraries do not follow this style |
|||
#+end_quote |
|||
|
|||
| Type | Style | |
|||
|---------------------+-------------| |
|||
| Class | Pascal Case | |
|||
| Function / Variable | Camel Case | |
|||
| Const / Definition | Snake Case | |
|||
|
|||
#+begin_src cpp |
|||
class FrenchVanilla : public IceCream { } |
|||
#+end_src |
|||
|
|||
#+begin_src cpp |
|||
const MAX_SCOOPS = 3; |
|||
#+end_src |
|||
|
|||
#+begin_src cpp |
|||
FrenchVanilla myIceCreamCone(MAX_SCOOPS); |
|||
#+end_src |
|||
|
|||
** Order of header inclusion |
|||
|
|||
*Eckel* broadly defines the order of inclusion[fn:eckel-2000]: |
|||
|
|||
#+begin_quote |
|||
Headers are included in order from "the most specific to the most general." That is, any header files in the local directory are included first, then any of my own "tool" headers, such as require.h, then any third-party library headers, then the Standard C++ Library headers, and finally the C library headers. |
|||
#+end_quote |
|||
|
|||
#+begin_src cpp |
|||
#include <myheader.h> // Local directory headers. |
|||
#include <mytools> // Personal tool headers. |
|||
#include <thirdparty> // Third party library headers. |
|||
#include <bits/stdc++> // C++ library headers. |
|||
#include <iostream> // C library headerts |
|||
#+end_src |
|||
|
|||
* Resources |
|||
|
|||
[fn:eckel-2000] Eckel, Bruce. Thinking in C++. 2nd ed, Prentice Hall, 2000, https://online.vitalsource.com/books/9781269392440. |
Write
Preview
Loading…
Cancel
Save
Reference in new issue