Imagine you go to an important convention and meet lots of important people who are interested in your upcoming game. You want to stay in contact, so they tell you their name and their e-mail address. And you tell them your name and your e-mail address. A name and an e-mail address are data.
Does that make sense so far?
If so, how do you remember these data? Can you learn everything by heart within seconds or do you need something that helps you remember, e.g. a notebook? Where does the data go when you forget something?
What about the people you met? How can they remember your name, let alone your e-mail address?
When you come home, does your best friend know about all the interesting people you met? Or do you have to tell him about them first?
The computer is not that different from you. The only difference is that it is not creative, it cannot remember anything, cannot interpret anything, cannot invent anything, and it needs strict, unambiguous instructions. Coding is nothing than providing clear instructions in a programming language.
The logic behind those instructions is independent from a specific programming language. In fact, you could even program without a computer. Train a bunch of chickens to do things in a specific order, and you have a program.
Do you know these Japanese devices in their gardens that are supposed to frighten away animals? I’m sure you can express the algorithm/logic/concept behind it in a few simple sentences: If X, then Y. If Y, then X. If you can do that, you are a programmer and have all the relevant skills to write code. It might be that you don’t know any programming language yet or do not know how to express your thoughts in a sequence of simple instructions but that’s something you can learn.
Back to the initial problem. You want to remember the important people because you want to show them your upcoming game. And you want them to remember you.
Imagine you had a business card with all the relevant information about you. You give it to people, and people give you theirs. Now all you have to do is to remember that you got business cards and where you put them. If you keep all your business cards in one place, you can keep track of the data. You can count how many people you met. You have their data right there. If you are messy, cards could get lost, and it is likely that you forget the names and/or e-mail addresses on the lost cards.
When you want to write an e-mail to all important people you met, all you have to do is to grab your stack of business cards and use the relevant data on them.
Since everybody can have a business card and since you could replace data on a card, you can regard the business card itself as a variable. A variable is a container for data.
In C#, you could express this concept of business cards like this:
BusinessCard myBusinessCard = new BusinessCard(
"Kevin",
"Indie Game Developer",
"email@address.com"
);
BusinessCard companyCard = new BusinessCard(
"John Doe",
"Important person in big company",
"john.doe@bigcompany.com"
);
BusinessCard instructorCard = new BusinessCard(
"Ben Tristem",
"Instructor in the Unity 3D course",
"some@test-test.com"
);
As long as the data is assigned to myBusinessCard
, and as long as the variable myBusinessCard
exists, you can pass this package of data/information on to other methods and objects within your program. The computer can the data from myBusinessCard
. Or from companyCard
.
Did this clear it up for you a bit?