These are the resources used for the Computer Science course Programming Principles, designed to teach students the fundamentals of computer programming and object orientation via learning the Java language. We also touch on some software engineering basics, such as patterns, software design and testing. The course assumes no previous knowledge of programming, but there is a fairly steep learning curve, and students are encouraged to practice, practice, practice!
Event driven programming is a way of writing a program that works by responding to things happening (rather than executing a preplanned series of tasks). It is most often used to manage more advanced user interactions, such as GUI programs. In this session we look at how event driven programming works in Java GUIs, as both an introduction to events (using MouseListeners), and also to the way that GUI programs are constructed.
In the example code you can see that when the remove(Object o) method is called the Integer is not cast to an int and the matching is done using the object's .equals() method rather than using ==
These are the resources for an introductory lecture in JavaScript programming. Exercises are provided to practice simple JavaScript programming, including a template for a DHTML implementation of Conway's Game of Life (with encrypted solution).
This is a batch file written to help students on ECS' Programming 1 course (COMP1202) using iSolutions machines which have the JDK, but do not add it to the PATH variable, making compilation from the command line difficult.
It attempts to find the JDK directory and add it to the Windows PATH.
The code is as follows:
@SET JAVA_HOME=C:\Program Files\Java
@FOR /F %%G IN ('DIR /B "%JAVA_HOME%\JDK*"') DO @SET JDK_HOME=%JAVA_HOME%\%%G
@SET PATH=%JDK_HOME%\bin;%PATH%
@javac -version
@echo.
@echo %JDK_HOME%\bin successfully added to Windows PATH
@echo.
@echo Now type 'javac'.
@echo.
@echo.
@echo.
@CMD
What is Programming?
A useful definition
Object Orientation (and it’s counterparts)
Thinking OO
Programming Blocks
Variables
Logic
Data Structures
Methods
Programming Overview
The JVM (The Java Virtual Machine)
A brief look at Structure
Class
Method
Statement
Magic incantations
main()
output
Coding a Dog
Programming Principle(1)
If and Boolean operations
Coding a Bank Account
Quick look at ToolBox
Inheritance
Code duplication
Super classes
Constructors
Polymorphic collections
“Anywhere a super class is, a sub class can go”
Casting
A great deception
Exceptions
An Example
The Throws keyword
Try and Catch
The flow
Multiple exceptions
Finally
How exceptions are thrown
What the complier checks
Handle or Defer
Recovery
Writing your own
In this session we look at how to use Abstract Classes and Interfaces in Object Oriented Design - especially as a way to get all the advantages of multiple inheritance without any of the problems.
In this session we look at how we can use collection objects like ArrayList as a more advanced type of array. We also introduce the idea of generics (forcing a collection to hold a particular type) and see how Java handles the autoboxing and unboxing of primitives. Finally we look at Iterators, a common design pattern for dealing with iteration over a collection.
In this session we look at how to think systematically about a problem and create a solution. We look at the definition and characteristics of an algorithm, and see how through modularisation and decomposition we can then choose a set of methods to create. We also compare this somewhat procedural approach, with the way that design works in Object Oriented Systems,
This is the revision session for our Programming Principles course. We take a whistle-stop tour of the topics covered in the course, look at the three pillars of object oriented programming, and look ahead to the exam.
In this session we look at the public and protected keywords, and the principle of encapsulation. We also look at how Constructors can help you initialise objects, while maintaining the encapsulation principle.
In this lecture we look at key concepts in Java: how to write, compile and run Java programs, define a simple class, create a main method, and use if/else structures to define behaviour.
In this session we look at how to create more powerful objects through more powerful methods. We look at parameters and call by value vs. call by reference; return types; and overloading.
In this session we build on inheritance and look at overriding methods and dynamic binding. Together these give us Polymorphism - the third pillar of Object Oriented Programming - and a very powerful feature that allows us to build methods that deal with superclasses, but whose calls get redirected when we pass in sub-classes.
In this lecture we describe the structure of the Programming Principles course at Southampton, look at the definitions and paradigms of programming, and take a look ahead to the key things that we will be covering in the weeks ahead.
In this session we point you at the Java Library, and go into some more details on how Strings work. We also introduce the HashMap class (a very useful type of collection).
In this session we look more closely at the way that Java deals with variables, and in particular with the differences between primitives (basic types like int and char) and objects. We also take an initial look at the scoping rules in Java, which dictate the visibility of variables in your program
In this final increment we will complete the GCU adventure game. This means we have to meet the following requirements that were not met in the previous increments:
The sequence of turns should repeat until a command is given to quit
At each turn, the player can type a command to specify the action which he or she wants to take during that turn
The player should be able to ask for help during any turn instead of navigating
Meeting these requirements will give a program that behaves like a game and allows the player to engage and interact with the game. It is worth noting that although the game is a very simple one which is not really fun to play, the model we have built, using sound object oriented principles and practices, would provide a solid basis for the development of a more complex and interesting version of the game.