programming ii l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Programming II PowerPoint Presentation
Download Presentation
Programming II

Loading in 2 Seconds...

play fullscreen
1 / 17

Programming II - PowerPoint PPT Presentation


  • 350 Views
  • Uploaded on

Programming II - Part 1 – Object Oriented Programming with Java Sebastian Uchitel www.doc.ic.ac.uk/~su2 Course Structure Lectures Room 308. Monday 14:00 and Friday 10:00. Tutorials Room 344 (and 308 if we need more space) Monday 15:00 Lab

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Programming II' - ostinmannual


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
programming ii

Programming II

- Part 1 –

Object Oriented Programming with Java

Sebastian Uchitel

www.doc.ic.ac.uk/~su2

course structure
Course Structure
  • Lectures
    • Room 308.
    • Monday 14:00 and Friday 10:00.
  • Tutorials
    • Room 344 (and 308 if we need more space)
    • Monday 15:00
  • Lab
    • 4 labs dedicated to topics covered in Programming II.
    • Week 2 (unassessed), and weeks 3, 5, and 6.
  • Assessment
    • 2 assessed assignments (one for each part of the course)
    • 2h exam, 3 questions out of 4

© S. Uchitel, 2004

part i aims
Part I - Aims
  • Learn concepts and fundamentals of the Object Oriented paradigm.
  • Apply in a real programming language (Java) these concepts and fundamentals
  • Learn Java
  • Practice problem solving using Java and OO principles.

© S. Uchitel, 2004

part i textbooks
Part I - Textbooks
  • Java Software Solutions – Foundations of Program Design (3rd ed.), Lewis and Loftus, Addison Wesley.
  • Thinking in Java (3rd ed.), Bruce Eckel, Prentice Hall. Freely available at http://www.mindview.net/Books/TIJ/
  • Java Documentation:
    • http://java.sun.com/docs/books/tutorial/
    • http://java.sun.com/j2se/1.4.2/docs/api/

© S. Uchitel, 2004

part i outline
Part I - Outline
  • Introduction
    • Motivation
    • From Kenya to Java
  • Objects and Classes: A User’s Perspective
    • What are they?
    • How do I create objects from classes, and how do I use them?
    • Where do I get classes from in the first place?
  • Objects and Classes: A Developers Perspective
    • How do I create my own classes?
    • How do I design “good” classes?
  • Inheritance and Polymorphism
  • Interfaces and Abstract Classes
  • Collections
  • Exceptions

© S. Uchitel, 2004

why object oriented programming
Why Object Oriented Programming?
  • Programming is about two things
    • Problem solving
    • Managing complexity
  • OO Programming provides conceptual framework and programming constructs for managing complexity
  • In principle with imperative and functional languages you can implement anything but...
    • Functional languages: input and output? acceptance in industry?
    • Imperative languages do not manage complexity well. More difficult to understand/maintain/extend.

© S. Uchitel, 2004

why learn java
Why learn Java?
  • Why Java?
    • Java is an OO programming language.
    • Widespread in Industry for development of traditional and web-based applications
  • Why not Kenya?
    • Kenya is not an OO programming language.
    • Developed at Imperial for educational purposes.
    • Outside Imperial College VERY few people know it.
    • Not used in Industry
  • Why not other OO programming languages?
    • C++? Complex (and confusing) mix between OO and imperative programming, memory management, and more...
    • Smalltalk? Pure? But, low acceptance in Industry, and more...

© S. Uchitel, 2004

from kenya
From Kenya...

void main() {

// Requests two numbers and prints the larger

println("Type in your 2 numbers -> ");

println("The winner is " +

bigger(readInt(), readInt()));

}

int bigger(int a, int b){

//post: returns the larger of the 2 valuesif (a > b) {return a;}

else {return b;}

}

To tool...

© S. Uchitel, 2004

to java
... to Java

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

© S. Uchitel, 2004

from kenya to java
From Kenya to Java
  • By adding the bits and pieces of the previous slide, you can now write Java programs for all the Kenya programs you did in the previous term!
  • However, in the next 10 lectures you will learn what these bits and pieces are!
  • Recommendations:
    • Throw the Kenya compiler away!
    • Write Java from the very first day!

© S. Uchitel, 2004

what s new classes
What’s new: Classes

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Classes

(In Java, nearly

everything appears

within one)

© S. Uchitel, 2004

what s new objects
What’s new: Objects

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Objects, object

methods and calls

© S. Uchitel, 2004

what s new command line parameters
What’s new: Command line parameters

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Command line parameters

© S. Uchitel, 2004

what s new packages
What’s new: Packages

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Packages

© S. Uchitel, 2004

what s new visibility and encapsulation
What’s new: Visibility and Encapsulation

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Visibility &

Encapsulation

© S. Uchitel, 2004

what s new class scope
What’s new: Class scope

import kenya.io.InputReader;

public classBigger {

public static void main(String [] args) {

System.out.println("Type in your 2 numbers -> ");

System.out.println("The winner is " +

bigger(InputReader.readInt(), InputReader.readInt()));

}

static int bigger(int a, int b){

//post: returns the larger of the 2 values if (a > b) {return a;}

else {return b;}

}

}

Class scope

© S. Uchitel, 2004

what s new much more
What’s new: Much more!
  • Inheritance
  • Polymorphism
  • Dynamic Binding
  • Casting
  • Overloading
  • Constructors
  • Abstract Classes
  • Interfaces
  • and much more!

© S. Uchitel, 2004