Skip to content

Commit

Permalink
New version for 24/25.
Browse files Browse the repository at this point in the history
Fixes Magnus comments.
  • Loading branch information
toasterbag committed Aug 16, 2024
1 parent 844af11 commit 01a5245
Show file tree
Hide file tree
Showing 21 changed files with 218 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Data101

A book targeting students that are starting a university programme related to computer science, specifically those at Chalmers University of Technology.
A book targeting students that are starting a university program related to computer science, specifically those at Chalmers University of Technology.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[book]
authors = ["Karl David Hedgren", "Love Lyckaro"]
authors = ["David Hedgren", "Love Lyckaro"]
language = "en"
multilingual = false
src = "src"
Expand Down
8 changes: 4 additions & 4 deletions src/advanced/editor.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Advanced usage
# Advanced usage of your editor

This section lists features that are useful for everyone but have more complex uses. It is recommended that you have at least started to write some code (even if it's just the intro course), otherwise, it may be difficult to understand what they do or why to use them.
This section lists features that are useful for everyone but have more complex uses. It is recommended that you have at least started to write some code (even if it's just in the intro course). Otherwise, it may be difficult to understand what these techniques do or why to use them.

## Shortcuts

First of you should know that it is possible to edit the shortcuts by opening `>Preferences: Open Keyboard Shortcuts`, you can also search for shortcuts here. The default shortcuts are primarily designed for users with American keyboard layouts and as such, some of them will be very unwieldy to use. Make your editor yours by changing as many shortcuts as you'd like!
First you should know that it is possible to edit the editor shortcuts by opening `>Preferences: Open Keyboard Shortcuts`. You can also search for shortcuts here. The default shortcuts are primarily designed for users with American keyboard layouts and as such, some of them will be very unwieldy to use. Make your editor yours by changing as many shortcuts as you'd like!

### Compose keys

Expand All @@ -16,6 +16,6 @@ If your code has errors you can easily go to the next error by pressing !kbd[!ct

### Format your code

It is easy to write messy code in the beginning, this makes it difficult for TAs and your friends to help you. It is recommended to enable the `Editor: format on save` option in the preferences so that your code will automatically be formatted when you save. It is also possible to manually format using !kbd[!ctrl+Shift+I].
It is easy to write messy code in the beginning. This makes it difficult for TAs and your friends to help you. It is recommended to enable the `Editor: format on save` option in the preferences so that your code will automatically be formatted when you save. It is also possible to manually format using !kbd[!ctrl+Shift+I].

> Formatting does not work when you have syntax errors so if the command doesn't do anything you might have to fix your code first!
2 changes: 1 addition & 1 deletion src/beginner/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There are several reasons as to why but it mostly comes down to that they are ve
## Installation

{{.windows}}
To get started on Windows you have to install WSL, if you have followed the instructions from [Getting started](../../getting_started.md) then you should already have it. Otherwise, go back and install it now.
To get started on Windows you have to install WSL, if you have followed the instructions from [Getting started](../../getting_started.md) then you should already have it. Otherwise, go back to that page and install it now.

> Windows also provides the native `PowerShell` and `cmd.exe` utilities. These work very differently from most other shells and are not used as often in the industry. Therefore we have decided not to focus on them in this book.
Expand Down
4 changes: 2 additions & 2 deletions src/beginner/editor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Long answer: When writing this guide we compared many editors to find out which

- Available on all platforms (Windows, macOS, Linux)
- Not specific to a certain programming language or environment (e.g. PyCharm which only works for Python)
- Extensive plugin support for all environments used in courses given by our department.
- Extensive plugin support for all environments used in courses at Chalmers.
- Does not require any computer knowledge to get started[^emacs_evangelists]

The only editor which truly fits all of these is Visual Studio Code.

## Setup

To get started, begin by downloading VSCode from their [webpage](https://code.visualstudio.com/).
To get started, begin by downloading VSCode from the [webpage](https://code.visualstudio.com/).

> **Did you know that you can open links in a new tab by either**
>
Expand Down
16 changes: 8 additions & 8 deletions src/beginner/editor/navigation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Navigation

Before writing code it is necessary to understand how to navigate it. Remember that this is all about muscle memory. You will have to train and it will feel uncomfortable, especially if you aren't used to using your keyboard extensively, but doing it now will make you fast as lightning by the time you graduate. You will probably neither feel motivated nor have the time when you are out working.
Before writing code it is necessary to understand how to navigate the editor. Remember that this is all about muscle memory. You will have to train and it will feel uncomfortable, especially if you aren't used to using your keyboard extensively, but doing it now will make you fast as lightning by the time you graduate. You will probably neither feel motivated nor have the time when you are out working.

## The caret

Expand All @@ -16,7 +16,7 @@ VSCode also includes a powerful tool called the `Command palette`. This may be t

There are four main modes of operation. The first and simplest one is to search for files in your project. Try creating a new file in your project, open the command palette and then type the beginning of the name and press !kbd[Enter]. This is a fast method of moving between files in your project.

It also has another function which is to run various tasks, such as opening preferences, building your project or opening a new terminal. This mode is accessed by prefixing the search with `>` or entered directly by pressing !kbd[!ctrl+Shift+P]. Anything that you can do by using your mouse can be done here. Try opening a file using the command palette!
The palette also has another function which is to run various tasks, such as opening preferences, building your project or opening a new terminal. This mode is accessed by prefixing the search with `>` or entered directly by pressing !kbd[!ctrl+Shift+P]. Anything that you can do by using your mouse can be done here. Try opening a file using the command palette!

We will learn more about the two remaining modes in the next sections.

Expand All @@ -35,22 +35,22 @@ Sometimes you want to find a certain string in a file. For example say that you

> This command also works in your browser and can be used to find text on websites.
This can also be used to replace text. Maybe that function name you invented at the start just isn't cutting it any longer so you decide to replace it. Rewriting this by hand is tedious and error-prone (what if you miss one place?). Luckily VSCode got us covered, you can use !kbd[!ctrl+H] (!kbd[!ctrl+Alt+F] on macOS) and !kbd[!ctrl+Shift+H] to replace occurences in the file and project, respectively.
This type of functionality can also be used to replace text. Maybe that function name you invented at the start just isn't cutting it any longer so you decide to replace it. Rewriting this by hand is tedious and error-prone (what if you miss one place?). Luckily VSCode got us covered. You can use !kbd[!ctrl+H] (!kbd[!ctrl+Alt+F] on macOS) and !kbd[!ctrl+Shift+H] to replace occurences in the file and project, respectively.

> It is also possible to perform more complex searches and replacements see [the reference](https://docs.microsoft.com/en-us/visualstudio/ide/finding-and-replacing-text?view=vs-2022) for more information.
There is actually one final tool which is even more powerful than a normal find-search. _The symbol search_. Briefly, a symbol is some sort of identifier in your code. It could be a function name, a variable or some other named construct. The symbol mode of the command palette lets you swiftly navigate to these, just the same as you would navigate to other files. To use this feature, prefix your command with `@`.
There is actually one final tool which is even more powerful than a normal find-search which is _The symbol search_. Briefly, a symbol is some sort of identifier in your code. It could be a function name, a variable or some other named construct. The symbol mode of the command palette lets you swiftly navigate to these, just the same as you would navigate to other files. To use this feature, prefix your command with `@`.

## Final notes

Searching text visually has several drawbacks. It is time-consuming, an inexperienced searcher may have to go through the whole file to find the text in question. It also breaks your flow. You can only keep a certain amount of information in your head at once. For a beginner this may just amount to a few lines of code, for someone experienced it may be several files at once. But in the end it is a finite amount and there is no need to let go of it when we have tools which can help.
Searching text visually has several drawbacks. It is time-consuming, an inexperienced searcher may have to go through the whole file to find the text in question. It also breaks your flow. You can only keep a certain amount of information in your head at once. For a beginner this may just amount to a few lines of code, while for someone experienced it may be several files at once. But in the end it is a finite amount and there is no need to let go of it when we have tools which can help.

Some people use `PageUp` and `PageDown` to move the window up or down one page at a time, others scroll the mousewheel to fly over a file. What these have in common is that they are _relative_ movements and searches. What we want is to ask the computer for something and get it without us having to filter the information.
Some people use `PageUp` and `PageDown` to move the window up or down one page at a time, others scroll the mousewheel to fly over a file. What these methods have in common is that they are _relative_ movements and searches. What we want is to ask the computer for something and get it without us having to filter the information.

Here are a couple of cherry-picked examples demonstrating the effectiveness compared to simply scrolling.

If you get an error that says `Error, undefined variable on line 32 in file 'main.py'`, then you may be tempted to scroll through `main.py` until you find the line. It would be much faster to use !kbd[!ctrl+G] and enter `32` to navigate to the correct line immediately.

You may have a large file (files with more than a thousand lines are not uncommon) and your friend tells you to look at the function `toLowercase`. You can, just like the previous example, scroll and search by eye. However you can also use the powerful symbol mode of the command palette (prefix with `@`). searching for `@tolowercase` will get you there without the need to search.
You may have a large file (files with more than a thousand lines are not uncommon) and your friend tells you to look at the function `toLowercase`. You can, just like the previous example, scroll and search by eye. However you can also use the powerful symbol mode of the command palette (prefix with `@`). Searching for `@tolowercase` will get you there without the need to manually scroll and search.

The most generic of these is the _Find word_ functionality (!kbd[!ctrl+F]). If your TA asks you to bring up anything on the screen, then this command will always get you something reasonable.
The most generic of the methods described above is the _Find word_ functionality (!kbd[!ctrl+F]). If your _Teaching Assistant_ asks you to bring up anything on the screen, then this command will always get you something reasonable.
10 changes: 5 additions & 5 deletions src/beginner/editor/shortcuts.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Using shortcuts

> Before starting you might want to download a project from the introductory course.
<!-- > Before starting you might want to download a project from the introductory course. -->

To give you a taste of what's to come, with VSCode focused, press !kbd[!ctrl+O]! and select a project on your computer. If you do not have one, either create an empty folder or download one from the introduction course.
To give you a taste of what's to come, with VSCode focused, press !kbd[!ctrl+O] (note that it is the letter O not zero) and select a folder containing a project on your computer. If you do not have one, either create an empty folder or download one from the introduction course.

Programming is all about using the keyboard, while the mouse is useful most of the time when using a computer, this is not one of them. Every action that can be done using your mouse can also be done without lifting your fingers from the keyboard.
Programing is all about using the keyboard. While the mouse is useful most of the time when using a computer, this is not one of them. Every action that can be done using your mouse can also be done without lifting your fingers from the keyboard.

You may be tempted to click on the screen to move the caret (the vertical line where text appears), save your file or create a new file, and while this works, it is horribly inefficient compared to using shortcuts. In the beginning, you may not notice this but as you go through the semester it will become second nature to you.

> #### !kbd[Ctrl] or !kbd[]?
>
> On Macs the !kbd[!win] key is replaced by !kbd[] and is usually used instead of the !kbd[Ctrl] key. This guide tries to match the shortcuts to the OS you have selected but may not alway be 100% accurate.
> On Macs the !kbd[!win] key is replaced by !kbd[] and is usually used instead of the !kbd[Ctrl] key. This guide tries to match the shortcuts to the OS you have selected in the top bar but may not alway be 100% accurate.
You can find most of the common shortcuts in our [cheatsheet](../../Assets/cli_editor_cheatsheet.pdf), printing one for yourself and bringing it along in your backpack is a good way remind yourself of what you can do with the editor. You should also use this as a reference durign this tutorial, but don't worry if you don't understand what all shortcuts do yet.
You can find most of the common shortcuts in our [cheatsheet](../../Assets/cli_editor_cheatsheet.pdf). Printing one for yourself and bringing it along in your backpack is a good way remind yourself of what you can do with the editor. You should also use this as a reference durign this tutorial, but don't worry if you don't understand what all shortcuts do yet.

[Task]
Try writing some text on a new line. What happens if you press !kbd[!ctrl+X] without selecting any text?
Expand Down
11 changes: 5 additions & 6 deletions src/beginner/git/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ what, as well as guiding you in merging your different versions of files. Git
lets you be fearless when changing your code, safe in the knowledge that
previous versions of your code are easy to access.

Git is something one will have to use during the program. In project courses,
Git is something you will have to use during both your studies and later during your professional career. In project courses,
the bachelor's and master's theses it is almost always a requirement. And in
nearly every course you will have assignments where collaboration will be far
easier if you and your lab partner know and use Git. In addition to this, Git is
Expand All @@ -20,13 +20,12 @@ In this tutorial, we will guide you through setting up the necessary software
and accounts for a modern Git experience. We will introduce you to the basic
concepts of version control. Finally, we will show a basic workflow for
collaboration with Git in the typical programming assignments you will encounter
in the program.
during your studies.

We do not assume that you are comfortable in the terminal, and will strongly
We do not yet assume that you are comfortable in the terminal, and will strongly
advise using the graphical program GitKraken to handle your git needs. This is
an excellent tool, that helps pedagogically visualize the version control
concepts. Do note that most users of Git do use the terminal commands. If you
an excellent tool that helps to pedagogically visualize the version control
concepts. With experience, most users of Git prefer to use the terminal commands. If you
are comfortable in the terminal or would prefer to learn that way right away,
look no further than this
[tutorial](https://www.freecodecamp.org/news/what-is-git-and-how-to-use-it-c341b049ae61/)

6 changes: 3 additions & 3 deletions src/beginner/git/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For macOS users, there are two ways to install Git which we recommend.

1. Use the Git bundled with XCode. Chances are that if you're going to program
on a Mac, then you are going to have to install XCode's command-line tools at
some point. Git comes bundled with XCode's command-line tools, check if you
some point. Git comes bundled with XCode's command-line tools. Check if you
have it installed by opening a terminal and typing:

```bash
Expand Down Expand Up @@ -36,7 +36,7 @@ For macOS users, there are two ways to install Git which we recommend.
git --version
```

2. Or you can install Git using Homebrew. Homebrew is a package manager for
2. You can install Git using Homebrew. Homebrew is a package manager for
macOS, basically a command-line tool for helping you install various
software. It is very useful for developers in various situations and can be
installed by following the instructions [here](https://brew.sh/). After
Expand Down Expand Up @@ -93,7 +93,7 @@ you log in with your CID. Which we recommend for school projects as it is withou
any extra setup, and has unlimited private repositories.

We recommend setting up a GitHub account, as this account comes with some
excellent student benefits.
excellent student benefits.

Sign up for an account [here](https://github.com), and while you're at it sign
up for the GitHub Student Developer Pack using your Chalmers email
Expand Down
Loading

0 comments on commit 01a5245

Please sign in to comment.