Overview

Course topics

Java

The main thrust of the class is about programming in Java. We will spend as much time as necessarry on the basic syntax, but we want to focus on the use of class libraries and Java coding style.

Problem solving and algorithms

The first step in writing a program is developing the algorithm. In general,
An algorithm is an ordered set of unambiguous ,executable steps defining a terminating process. At each step, it is clear what to do next. Ambiguity is in the eyes of the beholder. The algorithm maybe clear but the representation is not. 'Make a peanut butter sandwich' is clear enough for me but a small child needs more details. It must be something that can be done. Calculate all digits in pi is not. Count all the M&M's in a bag is. Things like the pi calculation that never end are of little use. Some algorithms are designed to be non-terminating like operating systems or medical monitors.
Algorithm representation is tricky. Using natural language leads to ambiguities. For example, time flies like an arrow has several meanings. It is important that all the partners agree on the terms used to build the representation. These are called primitives.
Programming languages are built to be unambiguous. We all agree what the primitives are and how they are combined. The compiler is the enforcer.
The primitives in a language have both syntax - what it looks like and semantics - what it means. The syntax of
assignment in Java is
a = b;

The semantics are that the value stored in b is copied to a.
  • Programs

  • A program is different from an algorithm. A program is a precise implementation of an algorithm and is written in a formal computer language. Designing one is the hard part of programming. A good approach is to first state clearly what problem is being solved. Then work out the algorithm that solves it. Test the algorithm by running it in your head on some test cases. Then implement the algorithm in a computer language, compile it and test the actual running application. We'll see examples of this as we go. First, a quick overview of object oriented programming, which is related to design.

    Overview of Object Oriented Programming (OOP)

    This is primarily the grouping of code and data together. Encapsulation and inheritance are the main features. This differs from structured programming mostly in syntax and the inheritance idea.

    Why OOP?


    What problem were we trying to solve? Mostly complexity and re-use. People noticed that code that was grouped together with the data it manipulated was easier to follow. Also, complex data problems could be simplified by making a graph of them.

    Definitions and principles