Principles of Object-Oriented Software Development

12
Principles of Object- Oriented Software Development The language Java

description

Principles of Object-Oriented Software Development. The language Java. The language Java. Introduction Terminology Expressions Control Objects Inheritance Techniques Summary. Java -- the dial-tone of the Internet 1995 Introduction at WWW3 - PowerPoint PPT Presentation

Transcript of Principles of Object-Oriented Software Development

Page 1: Principles of Object-Oriented Software Development

Principles of Object-Oriented Software Development

The language Java

Page 2: Principles of Object-Oriented Software Development

The language Java

Introduction Terminology Expressions Control Objects Inheritance Techniques Summary

Page 3: Principles of Object-Oriented Software Development

Java -- the dial-tone of the Internet

1995 Introduction at WWW3 1996 1.0 with AWT 1997 1.1.x with modified event handling 1998 version 1.2 (beta) with Swing

Design principles -- safety

a modern programming language ,C++ syntax, no pointers virtual machine (runs on many platforms) libraries: threads, networking, AWT downloadable classes, support for applets extensions and APIs: Beans, Swing, MEDIA, 3D

See: http://www.javasoft.com and http://java.sun.com/docs/books/tutorial

Page 4: Principles of Object-Oriented Software Development

Keywords:

• new, finalize, extends, implements, synchronized

Java overview

Language features:

no pointers -- references only simplify life garbage collection -- no programmers' intervention constructors -- to create and initialize single inheritance -- for refinement interfaces -- abstract classes synchronized -- to prevent concurrent invocation private, protected, public -- for access protection

Page 5: Principles of Object-Oriented Software Development

Type expressions

• basic types -- int, char, float, ...

• Array -- int ar[SIZE]

• String -- String[] args

• class -- user-defined

Page 6: Principles of Object-Oriented Software Development

Expressions

• operators -- + , - ,.., < , <= ,.., == , ! = ,.., && , ||

• indexing -- o[ e ]

• access -- o.m(...)

• in/decrement -- o++, o--

• conditional -- b?e1:e2

Assignment

var = expression modifying -- +=. -=, ...

Page 7: Principles of Object-Oriented Software Development

Control

• conditional -- if (b) S1; else S2;

• selection -- switch(n) { case n1: S1; break; ... default: ... }

• iteration -- while (b) S

• looping -- for( int i = 1; i <= MAX; i++) S

• jumps -- return, break, continue

Java -- control

Page 8: Principles of Object-Oriented Software Development

Hello World -- Java (1)

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } };

Page 9: Principles of Object-Oriented Software Development

Hello World - interface

public interface World { public void hello(); };

Hello World - class

public class HelloWorld implements World { public void hello() { System.out.println("Hello World"); } };

Java -- objects (2)

Page 10: Principles of Object-Oriented Software Development

Hello World -- Java (2)

import java.awt.Graphics; public class HelloWorld extends java.applet.Applet { public void init() { resize(150,50); } public void paint(Graphics g) { g.drawString("Hello, World!", 50, 25); } };

Java -- inheritance

Page 11: Principles of Object-Oriented Software Development

Java -- techniques

• applets -- extend your browser • servlets -- extend your server • networking -- urls, sockets • RMI -- remote method invocation • reflection -- meta-information • beans -- component technology • JNI -- writing native methods • javadoc -- online class documentation

Page 12: Principles of Object-Oriented Software Development

The language Java

• design principles -- safety

• terminology -- object, interface

• syntax -- like C++

• objects -- abstract data types, interfaces

• inheritance -- single inheritance

• techniques -- dynamic casts, reflection, APIs