Sunday, May 15, 2011

Variables

Programming is based on mathematics. Variables are used in the same manner as in an algebraic formula: storage. The only thing that is different is that they are much more advanced in what they can do. Variables are the most basic of objects used in programming.

Like in math, we need a place to store numbers. That is where variables for the type short, long, integer, and double are used.
short: Limited to being between -32768 and 32767
long: Limited to being between -2147483648 and 2147483647
integer: Limited to being between -2147483648 and 2147483647
double: Limited to numbers with decimals
The main difference between the different types is that they use different amounts of memory. In most cases short variables will suffice, unless you are working with really big numbers. Most people seem to default to integers since memory is not very limited any more, yet I still like to use shorts whenever possible.

Now what if you need to declare something other than a number? What else can variables store? Strings of characters are another common thing for programmers to store. A string in simply a list of characters that make up text.
This is a string.
There are to variable types that can store characters:
Char: Stores one character.
String: Stores an array of characters.
Again, the difference of the two types above is that the memory required to store one character and storing a list of them is very different. Most commonly a string is used verses a char.

Sometimes you may need to keep track of whether something is true or false. This is the core of a computer system relating directly to the binary in which it operates. As a variable, we call them of the type boolean. Any variable of the type boolean can store a value of either true or false.
Additional, you can store advanced objects into variables. Advanced objects are ones that you create using classes and structures. While these advanced variables might not seem very useful at first as you begin programming, later with more advanced programs you will find that they are very useful and save a lot of time.
Structures: As the name implies, a structure is an object that contains things, much like a house or a building does. While these things are not like those of a house, they are important to the programmer. The structure is a collection of other variables, like shorts and strings. The big difference between the basic variables and a structure is that a structure holds much more information then a basic variable.
Classes: A more advanced structure is called a class. Each class is similar to a structure as they hold many different variables, but in addition a class also can hold subroutines and functions that can be used to ensure that the data stored in the class is correct. This is very handy when it comes to classes that store calculated data by having the calculations occur automatically when a new object is dimensioned.

Visual Basic:
Dim number as short
Dim trueFalse as boolean
Dim myText as string
Structure customStructure

Dim name as string
Dim age as short
Dim phoneNumber as string

End Structure

Dim myStructure as New customStructure
Public Class customClass

Dim name as string
Dim age as short
Dim phoneNumber as string

Sub New(name as string, age as short, phoneNumber as string)

Me.name = name
Me.age = age
Me.phoneNumber = phoneNumber

End Sub

End Class

Dim myClass as New customClass

Wednesday, May 11, 2011

Getting started

Programming is not something that is static. As you continue to create progjects, you style and solutions will change. The basics of programming will not change, no matter the language that you are using.

Current programming technology encapsulates Object Oriented Programming (OOP) as the main basis for allowing interaction between the user and the computer. Event driven coding has replaced the old line coding in the early days of computers.

What is OOP? Objects surround us in the real world, yet most people probably don't examine the details of objects as fully as they could. Without objects, what would there be in the world? Think about what an really object is: It is a physical thing that you can touch, therefore it has texture, shape, coutour, weight, size, mass, and color. Depending on the object it may only have one purpose, or it could have several. Programming objects are the exact same, they have their own parameters and characteristics.

When I wrote code using DOS in a language called QBASIC, often times the programs were very limited in scope. Each program did one thing, and did it well. Now with todays technology, applications are required to do many things at the same time, and often are required to duplicate themselves to complete the task given. This is where objects are needed. As a programmer, you must identify all the aspects of what your object is made of. What is the problem that you are trying to solve with your program?

Event driven code is another important thing to learn about. Back with DOS, code executed line by line until the program was complete. This was before users could use a mouse to make selections, and the major of the computer systems were text based. Event driven programming involves code that only runs on an event, like the user clicking a button. Subroutines and functions become a big factor in event driven code, and thinking modularly is very important. Event driven code can stay dormant until it is used, or be used multiple times by the program.

The first post for #learningcode

I work at a college as the computer lab assistant of the library. While I consider myself to be above average in computer skill, I feel like my job is not very challenging. Answering questions all day about how to print a document and how to setup the formatting is no more a challenge then getting dressed in the morning. Therefore in my free time I do what I love: coding. Writing software makes you think, it is not an easy process that one can just memorize an answer to.

Coding is a skill. While anyone can do it, those who are more technically included and who are excellent problem solvers are more likely to succeed. I consider myself to be creative in my means, and detailed in my results. Debugging is a major part of programming, as is the user interaction.

Though my work in High School, to my many attempts to create a successful program that user want to use, I have learned a lot. Because of this, I have decided to start this blog, to help others with the theories of programming, and the aspects that cannot be forgot.

As a lab assistant, I see many aspiring programmers struggle with some of the most basic of programming ideas. It is my goal to help with the basics, so please feel free to ask any questions that you may have.