Tuesday, October 19, 2010

Project 11 - Problems Solving Techniques (part 5)

Arithmetic expressions, loops, arrays, logical expressions. These are all elementary subjects associated with beginning programming, and will stay with the programmer as long as they code. Arithmetic expressions make use of variables, constants and operators to make calculations. Variables come into play in most every equation a programmer will write and allow for almost infinite possibilities as to what equations you can write. Loops will continue running the same part of code until some condition is met, whether it's a simple counter or waiting for some input from the user to exit the loop. Care must be taken not to accidentally throw your loop into infinity, being off by just one in your count will mess everything up (called an OBO or Off By One error). Arrays are used to contain data, they can come in many dimensions. They can be used like a simple list of objects, (objects being any data type, i.e. integers, strings etc.) this kind of array is known as a one dimensional array, a grid of objects, known as a two dimensional array, and so on. Most languages can support arrays above 3 dimensions, which can be very confusing to work with. Logical expressions are true/false statements. These are primarily used for decision making, and come in to play mostly in IF statements, and loops. All of these functions need to be understood in order for higher level programs to be created. Once these concepts are understood, it is relatively simple to make a solution for a problem and translate that into using these concepts to fulfill the problem.

In doing anything you need to understand the basics. Understand at the very bottom what is required of you and move from there. Take driving a stick shift car as an example. You need to know 3 pedals, the clutch, the brake and the accelerator. You also need to know the turn signal, and the shifter. You need to know which positions on the shifter put you in what gear. You need to understand at how many RPMs you make a shift up or down. You need to know how to recover from a stall, in case that happens. You also need to know how all of these things interact with each other. So, the accelerator increases your speed and RPM, when you hit around 3 thousand RPM you let go of the accelerator and push in the clutch, move the shifter appropriately so you shift one gear up, and slowly release the clutch. This will reduce your RPMs somewhat, and allow for a greater speed. When you down shift you need to brake a down and as your RPMs drop repeat the same process, only shifting down instead of up, so after each shift your RPMs will go up instead of down. In order to properly drive a stick-shift car, you need to understand how all of this occurs so you won't stall your car or blow out your engine from pushing its RPMs up too much. Every little thing interacts with each other, and when you understand it all, to some degree, you can drive safely and with confidence.

No comments:

Post a Comment