Programming

Introduction

Wikipedia

Programming: Source code, application domain, algorithms, logic, language syntax, patch, art/craft/engineering, qualifications

Requirements analysis, specification, software architecture, coding, compilation, testing, debugging, documentation, integration, maintenance

History: Al-Jazari's robot, Jacquard loom, Babbage's Difference Engine and Analytical Engine, Hollerith's punched cards, direct binary, programmable, assembly language, high level language, abstraction (fourth/fifth generation), offshore outsourcing.

Algorithms, Inputs, Outputs, Termination, natural language, pseudo-code, flowcharts, programming languages, maximum and minimum values, searching, sorting,  Big O notation, greedy algorithm, recursion, Travelling Salesman Problem,

Methodologies: Top-Down structured, OOAD, MDA, E-R

Generations

First: machine code, entered as binary, octal or hexadecimal. Clumsy, slow, late 1940s and early 1950s.

Second: Assembly language. Better way to produce machine code but instructions still expressed in terms of machine actions.

Third: High level imperative. Examples: FORTRAN, ALGOL, BASIC, COBOL, PL1, ADA, Pascal, C. Express actions in logical terms removed from machine instructions. Not address parts of computer like CPU registers and memory. 

Programming paradigms

Wikipedia

UC Berkeley CS10: Programming Paradigms

Imperative/Algorithmic/Procedural;

Functional; GeomLab

Object-oriented (C++, Delphi, Java),

Declarative (Prolog)

List processing (LISP, Logo)

FORTH (in its own category).

Data types

Basic distinction: Scalar versus structured types. Scalar is single object with a single type e.g. integer, Boolean, real. 

Basic distinction: strongly typed languages versus weakly typed. Strongly typed languages (e.g. Pascal) insist that, in most circumstances, an integer is an integer (variant types allow flexibility). Weakly typed languages (e.g. Visual Basic) allow a variable's type to be set at run-time by data in it (VB is strongly typed as well).

Structured or complex types include one or more elements. Array is a vector or group of data objects of the same type, accessible by an index (e.g. [i]). A string is an array of characters. A record is a group of one or more data items that can be of the same or different types e.g. an integer and a string . A set is an unordered group of objects of the same type e.g. set of numbers in range 0-10.

Abstract data types (ADT) are complex data types with associated methods. e.g. a stack, which can be implemented as an array or using pointers, has operations of Pop and Push (add to stack and remove item from stack respectively). Stack is LIFO (Last In First Out, like a pile of plates). Queue is FIFO (First in First Out, like any orderly queue). Binary tree is organised by data held in each node - usually smaller items to left, larger items to right.

Statements

Constants: retains same value throughout e.g. a tax rate. Change it in one place and it changes everywhere.

Types: include system types, integer, real, Boolean, character plus user-defined e.g. ADTs, enumerated types (have order).

Variables: take on values at run-time. Variable types (Java but principles apply to all imperative languages); article

  • Fixed value: A variable initialized without any calculation and not changed thereafter (in effect a constant)
  • Stepper: A variable stepping through a systematic, predictable succession of values e.g. loop counter
  • Most recent holder: most recent value in a sequence e.g. a value inside a loop - value cannot be known in advance
  • Most wanted holder: A variable holding the best or otherwise most appropriate value encountered so far e.g. largest or smallest found in a list
  • Gatherer: A variable accumulating the effect of individual values e.g. a running total or an array that collects values for a calculation e.g. a mean
  • Transformation - A variable that always gets its new value with the same calculation from values of other variables
  • Follower: new value comes from the old value e.g. in a sequence such as Fibonacci
  • One-way flag - A two-valued variable that cannot get its initial value once its value has been changed (not in specification)
  • Temporary - A variable holding some value for a very short time only (not in specification)
  • Organizer - An array used for rearranging its elements, as in sorting (not in specification)

Assignment: give a variable a value.

Selection: if, case.

Repetition: (aka iteration, looping): for, repeat, while

Statement blocks: program, procedure, function, class, unit (in Pascal). Procedures and functions can take parameters (data passed in or out of procedure). Function returns single value. Parameter declarations in procedure/function header are formal parameters; parameters passed when function/procedure is called are actual parameters.

See algorithm to merge two files.

Software Engineering

Wikipedia

Back