Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programming 101
#1
Programming 101
By Dark Echo

Ok guys, i've decided to write a basic tutorial on programming in general, and then i will dive into further Visual Basics and programming standards and good habits. Now, lets begin the first topic..

Programming in General
Almost all programming languages have:
  • Data Types
  • Data Structures
  • Control Flow
What are each of these you may ask. Well, lets see. Data Types, are just types of data. Different languages have support for different types of data. Data Structures is the structure of the coding. The data has to be structure or the computer won't be able to use it. Different languages organise their data into different types of data structures. And now lastly, Control Flow. All languages control the execution flow somehow. The approach though differs from language to language.

Data Types
We can give data meaning by labelling them with a data type. We have data types because an integer can have the same binary number as a alpha-numetric character. This is where data types come in. We define certain data with a data type.

Typical Data types are:
  • Integers
  • Real Numbers
  • Characters
  • Strings
  • Booleans

Integers are basically whole numbers. Real Numbers are sometimes considered as Floats or Reals. They are usually fractions, which hold a decimal point. Characters are individual alpha-numetric characters. Sometimes are considered Char or Ch. Strings are characters grouped together. Booleans are basically either True or False.

Data Structures
Data Structures are an arrangement of data. It is convenient and efficient to arrange data of the same of varying types into a data structure. The simplest data structure is the one dimensional array. In some programming languages the programmer can define his/her own data structures.

Semantics and Syntax
All programming languages can be characterised by their semantics and their syntax. Semantics is the actual words, and what they mean. Syntax is how these words can be use together as a group.

Example: Java Programming Language
Code:
//Hello World Program in Java :)
class HelloWorld {
    public static void main (String args[]) {
        System.out.print("Hello World");
    }
}
Now, the braces {} have a semantic. They commerce and complete a specific set of program statements. But they also have a similar syntax, they must be used in a pair, and they can also be nested.

Programs consist of statements written in particular programming languages. Statements carry out specific tasks. For example, opening a file, reading from a file, doing a mathematic calculation, etc.

Programming Paradigms
Programming Paradigms. What are they? There are four main ones. Procedural, Declarative, Functional and Object Oriented. Please note that one language can have more than one paradigm.

Procedural: Programs are a sequence of statements (commands) which manipulate data to produce the desired computation.
Examples: C, C++, Visual Basic

Declarativie: A generic approach to solving problems is implemented. Programmers define new problems in terms of this generic problem solving approach.
Examples: SQL

Functional: Programmers take an abstract approach to writting code. The different functions of the software are viewed as 'black boxes'. One by one, these functions are carefully implemented and tested. When all functions are complete, they are integrated and the program is finished.
Examples: Python

Object-Oriented: The programmer defines certain objects and their characteristics in the 'real-world system' the program is emulating. These objects pass messages from one to another in order to function collaboratively. This also means that objects can be designed for a specfic and well designed purpose. They can be used over and over again, whenever needed.
Examples: C++, Java, Delphi, Visual Basic

Control Flow
Programs execute sequentially, from one statement to another, until they end. When writing programs, most of the time there are certain functions that require repetitive tasks. This is were they would use a construct. A construct, for example, is a loop. A choice contruct, for example, is an 'If Statement'.

Loop Constructs
There are 3 widely used looping control statements.
  • The while loop
  • The for loop
  • The until loop.

The while loop will check to see while this condition is true, keep looping. The for loop on the other hand is very different. There is an index and that index has an assigned value. As the program loops, it will increment the index. The loop will end once the index reaches a specific value. The until loop will keep looping until a the condition is true. A slightly different concept than the while loop.

Choice Control Constructs
There are 3 widely used choice constructs:
  • If-Then
  • If-Then-Else
  • Case

The If-Then is very easy to understand. If condition is true, then proceed. The If-Then-Else is similar to the If-Then, but with an added extra part. If condition is true, then proceed. If condition is false, then proceed. There is another set of statements to execute. The Case statement is totally different from the If-Then bunch. It is basically, in the case of condition n being true, then execute statement x. I used n and x because the programmer can have as many cases as they feel are necessary.

Another type of control flow allows for a remote program or the same program to be executed. These are called subroutines. They can also be called methods, procedures, functions, routines, etc. The use of subroutines facilitates simpler programming and is much more cleaner. It is also very good programming practice.

Well, thats some of the basics about programming.. Just a few tips:
  • Programming languages are not error tolerent
  • Take your time to think carefully, and cleanly.
  • Analyse your problem. How is the best most efficient way to solve it? What data types and structures do i need? What control statements work best?
  • Write a few statements, test, debug, iterate.
  • Enjoy yourself Big Grin

References:
Aho, A. V., Sethi, R. & Ullman, J. D., 1986, Compilers: Principles, Techniques and Tools, Addison-Wesley.
Brookshear, J. G., 2003, Computer Science: an overview (7th edn), Pearson Education, Inc, Ch 5.
Englander, I., 2003, The Architecture of Computer Hardware and Systems Software (3rd edn), John Wiley & Sons, Inc, Ch 17.
Kelleher, C. & Pausch, R., 2005, ‘Lowering the barriers to programming: A taxonomy of programming environments and languages for novice programmers,’ ACM Computing Surveys, Vol 37, no 2, pp 83-137.
Suganuma, T., Ogasawara, T., Takeuchi, M., Yasue, T., Kawahito, M., Ishizaki, K., Komatsu, H. & Nakatani, T., 2000, ‘Overview of the IBM Java Just-in-Time compiler,’ IBM Systems Journal, vol 39, no 1 p175.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)