# Topic 16 - 18
###### tags: `The Pragmatic Programmer`
## Topic 16 The Power of Plain Text
> Look at your raw materials, the stuff you’ll be shaping.
#### :star2: The best format for storing knowledge persistently is plain text.
### WHAT IS PLAIN TEXT?
*Plain text* is made up of printable characters in a form that conveys information.
We like our plain text to be *understandable* to humans
:::info
Keep Knowledge in Plain Text
:::
### THE POWER OF TEXT
Plain text doesn’t mean that the text is unstructured.
e.g. HTML, JSON, YAML
e.g. the fundamental protocols on the net: HTTP, SMTP, IMAP
#### **👍 good reasons**
1. **Insurance against obsolescence**
Human-readable forms of data, and self-describing data, will outlive all other forms of data and the applications that created them.
:::info
All software becomes legacy software as soon as it’s written.
:::
e.g. the difference between ***human readable*** and ***human understandable***
Consider a data file from some legacy system that you are given.
All that’s important to you is that it maintained a list of clients’ **Social Security numbers**, which you need to find and extract.
👍 human readable and understandable
```js
<FIELD10>123-45-6789</FIELD10>
...
<FIELD10>567-89-0123</FIELD10>
...
<FIELD10>901-23-4567</FIELD10>
```
👎 human readable but **not** human understandable
```
AC27123456789B11P
...
XY43567890123QTYL
...
6T2190123456788AM
```
👍👍 makes this task a no-brainer
```
<SOCIAL-SECURITY-NO>123-45-6789</SOCIAL-SECURITY-NO>
```
2. **Leverage existing tools**
- File comparison tools
- see at a glance what **changes** have been made: `diff` and `fc`
- generate a **checksum** to **monitor** the file for accidental (or malicious) modification: `sum`
3. **Easier testing**
If you use plain text to create synthetic data to drive system tests, then it is a simple matter to **add**, **update**, or **modify** the test data ***without having to create any special tools to do so**.*
### LOWEST COMMON DENOMINATOR
In heterogeneous environments the advantages of plain text can outweigh all of the drawbacks.
You need to ensure that all parties can communicate using a common standard. **Plain text is that standard.**
---
## Topic 17 Shell Games
> How can you use your computer to get the most out of the tools you use?
#### :star2: For a programmer manipulating files of text, that workbench is the command shell.
A **benefit** of GUIs is **WYSIWYG**—what you see is what you get. The **disadvantage** is **WYSIAYG**—what you see is *all* you get.
:::info
Use the Power of Command Shells
:::
### **A SHELL OF YOUR OWN**
> A developer should customize their shell.
Common changes include:
- ***Setting color themes.***
- ***Configuring a prompt.***
Personal preferences are everything here: we tend to like simple prompts, with a shortened current directory name and version control status along with the time.
- ***Aliases and shell functions*.**
Simplify your workflow by turning commands you use a lot into simple aliases.
- ***Command completion*.**
- zsh: https://ohmyz.sh/
---
## Topic 18 Power Editing
> Suggest ways of making you more efficient.
You need to be able to manipulate text as effortlessly as possible, because text is the basic raw material of programming.
:::info
Achieve Editor Fluency
:::
### **WHAT DOES “FLUENT” MEAN?**
What counts as being fluent? Here’s the challenge list:
- When editing text, move and make selections by character, word, line, and paragraph.
- When editing code, move by various syntactic units (matching delimiters, functions, modules, ...).
- Reindent code following changes.
- Comment and uncomment blocks of code with a single command.
- Undo and redo changes.
- Split the editor window into multiple panels, and navigate between them.
- Navigate to a particular line number. Sort selected lines.
- `Ctrl + G`
- Search for both strings and regular expressions, and repeat previous searches.
- Temporarily create multiple cursors based on a selection or on a pattern match, and edit the text at each in parallel.
- Display compilation errors in the current project.
- Run the current project’s tests.
You might say that your current editor can’t do some of these things. **Maybe it’s time to switch?**
### **MOVING TOWARD FLUENCY**
Look at yourself while you’re editing.
Every time you find yourself doing something repetitive, get into the habit of thinking “there must be a better way.” Then find it.
- [keyboard-shortcuts-macos.pdf](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf)
**Growing Your Editor**
When you bump into some apparent limitation of the editor you’re using, search around for an extension that will do the job.

### useful git command
- `checkout -` / `switch -`: return to previous branch
