Προσωπικά τα δύο πράγματα που με βοήθησαν πιο πολύ στην διδασκαλία της έννοιας της μεταβλητής είναι τα παρακάτω:
Α. Χρήση Αναλογιών με τον πραγματικό κόσμο.
Α1. φανταστείτε ένα κουτί με αδιαφανές περιεχόμενο που το χρησιμοποιούμε για να μεταφερουμε πράγματα. Το κουτί έχει ένα όνομα (aka όνομα μεταβλητής) το οποίο μπορούμε εμείς από εξώ να δούμε και επίσης ξέρουμε ότι το κουτί μπορεί να μεταφέρει μήλα (και όχι πορτοκάλια, καραμέλες κτλπ). Αλλά κάθε φορά που το χρησιμοποιούμε δεν μπορούμε να ξέρουμε πόσα μήλα περιέχει.
έτσι αντί να αναφερόμαστε στο πόσα μήλα μεταφέρουμε κάθε φορά είναι πιο βολικό να αναφερόμαστε στο κουτί.
Α2. Μια δεύτερη αναλογία είναι η αυτή του ταχυδρομικού κουτιού που περιγράφεται στο paper
http://www.aueb.gr/pympe/hercma/proceedings2007/H07-FULL-PAPERS-1/DOUKAKIS-GRIGORIADOU-TSAGANOU-1.pdfΒ.Επίσης με βοήθησε πολύ αυτό που είχα διαβάσει κάποτε σε ενα C++ tutorial το οποίο παραθέτω δυστυχώς στα Αγγλικά γιατι δεν έχω το χρόνο να το μεταφράσω:
Let us think that I ask you to retain the number 5 in your mental memory, and then I ask you to memorize also the number 2 at the same time. You have just stored two different values in your memory. Now, if I ask you to add 1 to the first number I said, you should be retaining the numbers 6 (that is 5+1) and 2 in your memory. Values that we could now for example subtract and obtain 4 as result. The whole process that you have just done with your mental memory is a simile of what a computer can do with two variables. The same process can be expressed in C++ with the following instruction set:
a = 5;
b = 2;
a = a + 1;
result = a - b;
Obviously, this is a very simple example since we have only used two small integer values, but consider that your computer can store millions of numbers like these at the same time and conduct sophisticated mathematical operations with them.
Therefore, we can define a variable as a portion of memory to store a determined value.
Each variable needs an identifier that distinguishes it from the others, for example, in the previous code thevariable identifiers were a, b and result, but we could have called the variables any names we wanted to invent,as long as they were valid identifiers.
Ελπίζω να βοηθήσει
ευχαριστώ