Skip to content

Commit

Permalink
Merge commit '6105c4887434c4565d07ff9269a2db0c537a0a53' into 05_Concu…
Browse files Browse the repository at this point in the history
…rrency

# Conflicts:
#	better-code/00-preface.md
#	better-code/01-types.md
  • Loading branch information
FelixPetriconi committed Mar 13, 2021
2 parents df7dbea + 6105c48 commit c394e78
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion _posts/2020-02-26-revisionist-history-of-move.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Compare the description for the old [SGI STL LessThanComparable concept](http://
> We need wording to state that these are requirements for operations with the domain of values passed to the STL component. Borrowing from [the text for input iterators](http://eel.is/c++draft/iterator.cpp17#input.iterators-2):
{: .comment }

> The term _domain_ of an operation is used in the ordinary mathematical sense to denote the set of values over which an operation is (required to be) defined. This set can change over time. Each component may place additional requirements on the domain of an operation. These requirements can be inferred from the uses that a component makes of the operation and is generally constrained to those values accessible through the arguments of the operation. \[ _Example:_ The call `find(a, b, x)` is defined only if the value of `a` has the property _p_ defined as follows: `b` has property _p_ and a value `i` has property _p_ if (`*i == x`) or if (`*i != x` and `++i` has property _p_). _— end example_ \]
> The term _domain_ of an operation is used in the ordinary mathematical sense to denote the set of values over which an operation is (required to be) defined. This set can change over time. Each component may place additional requirements on the domain of an operation. These requirements can be inferred from the uses that a component makes of the operation and is generally constrained to those values accessible through the operation's arguments. \[ _Example:_ The call `find(a, b, x)` is defined only if the value of `a` has the property _p_ defined as follows: `b` has property _p_ and a value `i` has property _p_ if (`*i == x`) or if (`*i != x` and `++i` has property _p_). _— end example_ \]
{: .proposed}

### Option 1
Expand Down
10 changes: 5 additions & 5 deletions better-code/00-preface.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ tags: [ better-code ]
chapter: 0
---

To understand what _better code_ is we first need to understand what _good code_ is. Students are often taught that good code is code that does what the specification says it should. But such an answer begs the question of what is a good specification? Nearly every experienced developer I've met has a snippet of code filed away that has profound beauty - it likely has no corresponding specification and may not even contain a single comment. So what is good code?
To understand what _better code_ is, we first need to understand what _good code_ is. Students are taught that good code is code that does what the specification says it should. But such an answer begs the question of what is a good specification? Nearly every experienced developer I've met has a snippet of code filed away that has profound beauty - it likely has no corresponding specification and may not even contain a single comment. So what is good code?

By working through this book and applying the ideas within I hope that you will gain a deeper understanding of what good code is, and in striving to write good code you will write better code.
By working through this book and applying the ideas within, I hope that you will gain a deeper understanding of what good code is, and in striving to write good code, you will write better code.

This book presents a collection of software development goals. The word _goal_ was chosen carefully. These are not guidelines or rules, and achieving the goal is not always simple or straightforward. Each goal is phrased such that it is not prescriptive, and often states what not to do, but what _to do_ is an open-ended challenge. You will find that while trying to apply these goals you will sometimes fail, but through the effort you will gain a deeper understanding of your code and learn to write _better code_.
This book presents a collection of software development goals. The word _goal_ was chosen carefully. These are not guidelines or rules, and achieving the goal is not always simple or straightforward. Each goal is phrased such that it is not prescriptive and often states what not to do, but what _to do_ is an open-ended challenge. You will find that while trying to apply these goals, you will sometimes fail, but through the effort, you will gain a deeper understanding of your code and learn to write _better code_.

The examples in this book are primarily in C++, this is for two reasons. The majority of my professional career has been spent writing C++ code. I also believe it is the best mainstream language with which to present the ideas within, but at times I will point out some significant shortcomings. The ideas in this book are not limited to the C++ developer, but apply equally if you are programming in any other language. Where I think there is value in illustrating this point I provide examples in other languages. <!-- REVISIT: It may just be JavaScript as the other language, as yet undecided -->
The examples in this book are primarily in C++ for two reasons. The majority of my professional career has been spent writing C++ code. And C++ is the best mainstream language to present the ideas within, but I will also point out some significant shortcomings. The ideas in this book are not limited to the C++ developer but apply equally to other languages. Where I think there is value in illustrating this point, I provide examples in other languages. <!-- REVISIT: It may just be JavaScript as the other language, as yet undecided -->

<!--
Format for each chapter:
short introduction that provides motivation
a short introduction that provides motivation
explain the problem
show examples
define the goal
Expand Down
6 changes: 3 additions & 3 deletions better-code/01-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ And an _object_ is defined as:

> An object is a representation of an entity as a value in memory. {::comment}Add reference to section 1.3 of Elements of Programming{:/comment}
The fact that an object exists _in memory_ is important. Objects are physical entities and as such are governed by the laws of physics, despite being oft referred to as _virtual_.
The fact that an object exists _in memory_ is important. Objects are physical entities and are governed by the laws of physics, despite being oft referred to as _virtual_.

The basic building block for modern computers is the transistor. A transistor is a solid-state electronic switch. Prior to the use of transistors (the first transistor-based computer was built in 1953{::comment}Citation{:/comment}) computers were built with vacuum tubes, relays, or gears. {::comment}citation{:/comment} Any device that can serve as a controlled switch can be used to build a computer.
The basic building block for modern computers is the transistor. A transistor is a solid-state electronic switch. The first transistor-based computer was built in 1953{::comment}Citation{:/comment}. Prior to the use of transistors, computers were built with vacuum tubes, relays, or gears. {::comment}citation{:/comment} Any device that can serve as a controlled switch can be used to build a computer.

{% include figure.md name='transistor' caption='Transistor' %}
{% assign figure-transistor = figure-index %}

The symbol for a simple transistor is shown in {{figure-reference[figure-transistor]}}. A voltage applied to the base allows current to flow from the collector to the emitter.
The symbol for a simple transistor is shown in {{figure-reference[figure-transistor]}}. Applying a voltage to the base allows current to flow from the collector to the emitter.

{% include figure.md name='relay' caption='Relay' %}
{% assign figure-relay = figure-number %}
Expand Down
Loading

0 comments on commit c394e78

Please sign in to comment.