### Teaching concepts

• Teaching concepts

• Samples of concepts:

 Data types Variables Binary number system ...

• The what and why of concepts:

• Instructors often only teach:

 The definition of the concept I.e.: the what of the concpet

• I believe that you also must teach:

 The why of a concept

• The what of some computer science concepts

• Examples of the "what" of some concepts:

• Data type:

 ``` int x; // defines an integer variable x // x can hold a "whole number value" ```

Some explanation:

 A data type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored. (From an older entry in Wikipedia) a data type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. From: Wikipedia)

• Variables:

 ``` int x; // reserve memory locations to store an // integer value // The memory location is identified // by the name "x" ```

• Binary numbers:

 ``` 235 (dec) = 2 * 102 + 3 * 101 + 5 * 100 1101 (bin) = 1 * 23 + 1 * 22 + 0 * 21 + 1 * 20 = 15 (dec) How to convert bin to dec and vice versa ```

Teaching the what is easy, but not insightful (not really understanding why we need them).

• The why of data type

• Why do we use data types:

• Fact:

 Computers can only store numbers

• However:

 Computers need to store different kinds of information

Example:

 Gender info: 0 = male, 1 = female Marital status: 0 = single, 1 = married, 2 = divorced, 3 = widowed Boolean: 0 = false, 1 = true

• Observation:

 The value 0 can mean: male or single or false !!!

• Why use data type:

• The meaning of the representation depends on its data type"

 ``` Gender x = 0; // male MaritalStatus x = 0; // single boolean x = 0; // false ```

0 is actually a code !!!

Data type provides the context to interpret the code !!!

Note:

 Some data type uses a very elaborate code            E.g.: integer uses 2's complement code;          float uses IEEE 754 code.

• Prelude to the why of the number system: what is a value ???

• Misconceptions about the decimal number system:

• We grow up having been brain-washed into the decimal number system:

 ``` Symbols: 0 1 2 3 4 5 6 7 8 9 ```

Misconception:

 We think these symbols has implicit meaning..... They do not !!

• A common explanation of the binary number system:

 ``` 1010 (bin) = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 2 ```

What does this equality really mean ???

• Values and their representations:

• Values are intrinsic:

 A value does not depend on your cultural background

Example: what is the value 3 ???

 Suppose you ship-wrecked on a deserted island The inhabitants have a completely different culture (including language and number system) You want to trade your shoes for 3 coconuts You write "3" in the sand and points to the coconuts that belong to the native The native gives you one coconut because he does not recognize what "3" means. You then raise 3 fingers The native gives you 3 coconuts because he does recognize what 3 fingers mean

• Representing a value:

• The most meaningful way to represent a value:

 ``` One: * Two: ** Three: *** and so on ```

• Western way to represent values:

 ``` One: 1 Two: 2 Three: 3 and so on ```

Note: these symbols has no meaning to someone that is not educated in the west !!!

• Other ways:

• Roman:

 ``` One: I Six: VI Two: II Seven: VII Three: III Eight: VIII Four: IV Nine: IX Five: V Ten: X and so on ```

• Chinese:

 ``` One: 一 Six: 六 Two: 二 Seven: 七 Three: 三 Eight: 八 Four: 四 Nine: 九 Five: 五 Ten: 十 And so on... ```

Note: these symbols has no meaning to someone that is not educated in that culture !!!

• The why of the number system:

• Number system:

 Number system = a representation (= encoding) for values

• Positional value representaion:

• A position representation system is:

 an encoding system where the position of the digit determines the value that the digit represents !!!

Example:

 ``` 22 ^^ || Position: 10 the digit 2 at position 0 means: * * the digit 2 at position 1 means: ********** ********** ```

• What does this really mean:

 ``` 1010 (bin) = 1 * 23 + 0 * 22 + 1 * 21 + 0 * 2 It really means: 1010 (bin) = 1(********) + 0(****) + 1(**) + 0(*) = ******** + ** = ********** = 10 (decimal) ```

• Why do we use positional systems:

• Before the invention the positional system:

 Humans need to use abacus to perform additions (and multiplications)

• The positional system along with the memorization of the addition table:

 Transforms a piece of paper into a computing instrument !!!

• Illustrating new concept: use analogies

• Personal experience:

 Students can understand new concepts easier through an (accurate) analogy with something they are familiar

• Example: analogy for RAM memory:

• Mail boxes: