How to Learn Programming
Learning to program is a lot like learning a foreign (natural) language.
After all what you are learning is how to communicate with a computer. And, note,
the communication goes in two directions!
Vocabulary
You must memorize vocabulary.
- Read the text for definitions and explanations. Ask questions in class!
- Do the assigned reading quizzes.
- Practice & Drill.
WileyPlus has flashcards on its website:
- Go to the tab Read, Study & Practice
- Choose a chapter.
- Select FlashCards
.
Grammar/Syntax
Grammer is about how words are put together into meaningful statements.
You must understand, memorize, and practice the grammar (i.e. syntax). In each chapter, our textbook highlights the syntax in boxes, e.g.
.
You must also become familiar with how the computer responds when you have a mistake and so it doesn't understand what you have written, e.g. compiler errors.
Simple Scenerios/Tasks
When learning a foreign language, you usually are given short, prepared short conversations in specific scenerios, e.g. ordering a meal in a restaurant,
asking for directions on the street. The conversations help you understand and practice
how the vocabulary and grammer are used in a typical situation. You must listen to and speak the specific conversation many times until it becomes
natural and second nature. [cartoon]
Similarly, in programming, the best way to understand the vocabulary and syntax is to write short programs that do specific simple and common tasks, e.g.
prompting the user for their name, or adding a set of numbers. These help you see how the vocabulary and syntax work.
You must practice by typing the code into the computer repeatedly until you can do it easily and automatically, without looking at the solution code.
Small Variations
Once you have mastered the specific scenerio (i.e. task), the next step is to slightly vary the scenerio. If you understand the
vocabulary and syntax from the specific scenerio, you should be able to figure out what must be changed to fit the slightly altered scenerio.
For example, prompting the user for their age, or multiplying a set of numbers.
Written Exams
The written exams in this class will be based on the above, for example:
- Knowing vocabulary and syntax
- Given a short snippet of code, knowing what the output of the code will be.
- Being able to write (yes, on paper) a short segment of code that does a simple task.
Programming Problems and Problem Solving
When you are given a problem to code which is more complex than the above:
- Don't panic!!!! Take a deep breath. You aren't suppose to know how to solve the entire solution right away. Programming takes time, doing
little bits at a time until, low an behold, you have the whole thing finished. [cartoon]
- Don't jump immediately coding.
- Make sure you understand what you are being asked to do, e.g. if you are implementing a game, are the rules of the game completely clear?
- Make a design: On paper, draw pictures or write in plain english, the sequence of steps (the algorithm) that need to be done
(try to be complete but don't sweat it if step are missed - no one gets it exactly right the first time through!).
- This is the key: Break the problem into small doable subproblems, e.g. reading input, etc. where each small part
is some variation of a simple scenerio you already know well.
- When you are ready to start coding, implement one part at a time. Don't proceed to next part until you are sure the
current part is working properly. [cartoon]
This way, you will make debugging a lot easier.
[cartoon][cartoon][cartoon]
The real, ultimate goal is to be EXPRESSIVE and CREATIVE!
[cartoon]
Once you get to know a language, you can read interesting literature, express complex ideas, write letters, poetry, novels etc.
In programming, you can design and implement your own software to do things that you want to do e.g. art, music, science, games, etc.
Art Generated by Computer