Computer programming introduction

  • Computer programming introduction

This is an introduction to Computer Programming.

Let's start off with the basics, most first hand experience with programming is at secondary school in Computing class. Most schools use a Windows based client-server TCP/IP network, so Microsoft Visual Basic is probably the programming language employed. VB is an event-driven language meaning that the execution of code is triggered by an event, like a button press or keystroke. The code is executed line by line within it's procedure/control. VB also handles multiple data types such as Integers, Strings, Booleans (two way switch variable) etc... and is very versatile indeed (VB can be used to create calculator software, but can also be used to create an interactive snakes and ladders game) .

Colleges and Universities tend to use different types of programming languages, such as Object Orientated (like Java), Declarative (like SWi Prolog, programming in logic!) etc., these are usually only explored in theory at secondary school level. Some may also dabble in assembler (usually only used with the making of driver software), which is a set of mnemonics that carry out basic, low level arithmetic/data transfer instructions, for example MAZAM, the assembly language emulator is commonly used for educational purposes, and many of these emulators can even be web applet based (using plug-ins such as Shockwave/Java/Flash/Javascript). One would usually only study assembler languages while studying Computer Architecture, which is the study of processors (namely RISC and CISC), their development, and the trends with RAM and PCI as well.

Binary is also commonly studied as part of a computer programming course as well as the heirarchies and terminology e.g. bit, byte, gigabyte, terabyte, petabyte etc.. Data constructs are usually introduced at Advanced Higher(Scotland)/A-Level(England)/HNC/First year of Computer Science degree. The common data structures are stacks, queues, 2-D arrays and records. The philosophy and practical applications of the aforementioned are also very important to take into consideration.

A stack is used in many video games such as Pokemon for tracking the positions of the six Pokemon in the party as each Pokemon corresponds to an index of the stack array, and the Pokemon that corresponds to the stack pointer is withdrawn and popped. Any stack overflow, when the party has more than six Pokemon (i.e. when a Pokemon has been caught), spills over to the virtual Pokemon storage system introduced in Pokemon Blue/Red/Yellow. Stacks are also used to maintain web browsing history in many popular web browsers, and are also used to maintain a list of the locations read from in DDR-RAM.

Queues work on a wrap-around basis(as it would be efficient with processor time, as other processes may be contending to access the processor, and is also memory efficient), but with the exception of the aforementioned, they work rather like a supermarket queue. Keyboard buffers often employ queues, and printing queues in modern operating system software would also employ queues as well.

The ideas of Arrays are explored relatively early in any programming class or course , and is basically a set of data all contained within the one variable. Although physically it would just be binary, logically it is a set(essentially an array/list), linear list padded out with indexes to store each value. 2-D arrays, are less linear, these are more like grids and are good for maintaining things like the state of a virtual chess/draughts game. Records store multiple data types under the one variable and are good for storing, say phone numbers, names and a postcode all under one variable type.

Algorithms such as the sorting algorithms and searching algorithms are also very important to know. As a Computer Scientist/Programmer, these will become second nature to you like day to day speech almost! The simple sort is slow and linear, and does a comparison against each adjacent item in the array, the selection sort uses a second array, and shifts everything into order into the second array. The original array can then be disregarded. The binary search "chops" a sorted list in half each time, disposing of the half that will never contain the item that it is looking for. There are many more algorithms, but I could almost write a thick, chunky book devoted to them! Hopefully this introduction has enhanced your knowledge and perception of computer programming, and if you choose to study this field, I wish you the best of luck! :)


Before you start

Initial planning always wins over diving straight into code?! Yes, because you will get mixed up simply just because diving straight into coding without a formal, initial design to verify your code/project against, will be confusing as the project expands. Also, if you have a plan, that will save time! Over time, programming teams have come up with ways of managing time, check out Gantt/Pert charts for more information on time management when it comes to programming! The ADITDEM acronym (Analysis, Design, Implementation, Testing, Documentation, Evaluation and Maintenance) also helps programmers/project managers verify that everything has been done with regards to the software in development including all of the relevant documentation!


Safety first

Although this is not strictly programming, I want to talk about health and safety when it comes to programming. If you will be programming/typing a lot given your course, invest in an ergonomic keyboard, which will relieve your wrists of some unnecessary pain, which can develop into more serious,complex problems if left ignored. Also, try not to sit in front of a bright monitor for too long, many operating systems and even monitors themselves boast features that allow you to reduce the brightness of the display, that should help relieve your eyes from some of the strain you may experience. Plus, go out for a walk/into the fresh air, nobody can be a 24/7 code monkey after all :) Programming is part science and part craft


Example of VBA

Dim strSelecteditem As String
Dim intSelectedQuantity As Integer
Dim intSelectedRow As Integer
Dim intID As Integer
Dim currPrice As Currency
Dim strItem As String
Dim strlistOrder As String

intSelectedRow = Me.listOrder.ListIndex
intID = Me.listOrder.Column(0, intSelectedRow)
strItem = Me.listOrder.Column(1, intSelectedRow)
intSelectedQuantity = Me.listOrder.Column(2, intSelectedRow)
currPrice = Me.listOrder.Column(3, intSelectedRow)

Me.listOrder.RemoveItem intRowSelected

' This part of the code allows the user decrease the quantity by one if they click the item in the order table.

If intSelectedQuantity > 1 Then

intSelectedQuantity = intSelectedQuantity - 1
strlistOrder = intID & ";" & strItem & ";" & intSelectedQuantity & ";" & currPrice
Me.listOrder.AddItem StrlistOrder

End If

End Sub