ppt - Institut für Informatik

advertisement
4th Workshop “Software Engineering Education and
Reverse Engineering”
Zagreb, 5 – 12 September 2004
Existing programming teaching
materials
Section ‘Course: Object-Oriented Programming with Java’
(OOJava)
Živana Komlenov
Department of Mathematics and Informatics
Faculty of Science
University of Novi Sad
Goal
• Our ultimate goal: Creation of joint teaching material
for ‘Course: Object-Oriented Programming with Java’
(OOJava).
• As an important part of the whole project special
attention should be paid to high quality examples.
• Therefore, forming a pool of examples and student
assignments has been started.
• Work is in progress, so all contributions are still
welcome.
2
Živana Komlenov: Existing programming teaching materials
Existing programming
teaching materials
• Currently 6 Java courses are taught at some of our
member universities.
• Their examples have been gathered (texts of the
examples + source code with comments (any existing
versions)), analyzed and sorted in an appropriate way.
• The emphasis is not on examples that are directly used
during the lecture, but on every other kind of
supporting examples (student self-study, assignments,
lab exercises, longer examples for seminar/semester
papers, ... )
3
Živana Komlenov: Existing programming teaching materials
Division of examples
• Principal suggestion was to divide the examples
into at least three groups:
– Supporting Java examples - extra examples, similar to
those presented during the lecture, intended to
encourage students' individual experimenting.
– Short exercises - for instance, practical assignments,
lab exercises, etc.
– Longer examples - more complicated tasks, given as
seminar assignments, with longer deadlines (up to
several months).
4
Živana Komlenov: Existing programming teaching materials
Division comments
• However, there is no perfect way to draw the line
among these groups, so all suggestions or different
concepts of the division are very welcome.
• Additionally, we are going through some open - source
Internet materials, as well as good textbooks used
worldwide in similar courses.
• The idea is to collect useful pieces of information and
include them in our project.
5
Živana Komlenov: Existing programming teaching materials
Contributors
• Institute of Informatics, Humboldt University, Berlin
• Department of Mathematics and Informatics, Faculty of
Science, University of Novi Sad
• Department of Computer Science and Engineering,
Faculty of Electrical Engineering, University of Belgrade
• Chair of Computer Science, Mathematical Faculty,
University of Belgrade
• Computer Science and Engineering Department, Faculty
of Automation and Computer Science and Engineering,
"Politehnica" University of Timisoara
6
Živana Komlenov: Existing programming teaching materials
Institute of Informatics,
Humboldt University, Berlin
• Prof. Klaus Bothe
• Course: Practical Informatics I
– First semester course
– Last time taught in winter semester 2001/2002
– Computers, algorithms, data, programs, concepts of
programming languages, imperative and object-oriented
programming, programming techniques, bases of systematic
software development
– Followed by Java examples
7
Živana Komlenov: Existing programming teaching materials
Institute of Informatics,
Humboldt University, Berlin
• Contributions:
– Java examples used in the lecture, suitable for
Supporting Java examples group
– Assignments, some included in Short exercises
– Java examples used during the exercises, suitable
for section Short exercises
8
Živana Komlenov: Existing programming teaching materials
DMI, Faculty of Science,
Novi Sad
• Prof. Mirjana Ivanović
• Course: Programming Languages
– (semester 3, 2 hours/week lecture + 1 hours/week exercises
+ 1 hours/week lab
– semester 4, 2 hours/week lecture + 1 hours/week exercises +
2 hours/week lab)
– History of programming languages. Basic characteristics of
programming languages and most common differences.
– Object-oriented methodology: design and programming.
Principal elements: classes, inheritance, dynamic binding.
Review of some hybrid object-oriented languages.
9
Živana Komlenov: Existing programming teaching materials
DMI, Faculty of Science,
Novi Sad
– Java. Program structure. Data types, classes and objects.
Control and repetitive commands. Structured data types.
Methods, class libraries.
– Scheme; PROLOG
– Exam: practical + oral
• Contributions:
–
–
–
–
10
Examples from exercises
Lab assignments, some solutions
Written exams, some examples included in Short exercises
Seminar assignments, included in Longer examples
Živana Komlenov: Existing programming teaching materials
DMI, Faculty of Science,
Novi Sad
• Prof. Zoran Budimac
• Course: Operating Systems I
– (semester 5, 2 hours/week lecture + 2 hours/week exercises +
1 hours/week lab)
– History and development of operating systems. Programming
languages suitable for OS implementation. Concurrent
programming.
– Processes. Stages. Implementation. Interprocess
communication and synchronization. Process
communication. Deadlocks.
– Modula-2 and Java examples.
11
Živana Komlenov: Existing programming teaching materials
DMI, Faculty of Science,
Novi Sad
– Memory management. Physically available internal memory.
Virtual memory organization and management. External
memory. File systems.
– Exam: practical + oral
• Contributions:
– Java examples from exercises, suitable as one of the last
parts of Supporting Java examples – thread synchronization
– Practical assignments (some solved with GUI, as applets,
etc.), included in Short exercises
12
Živana Komlenov: Existing programming teaching materials
DCSE, Faculty of Electrical
Engineering, Belgrade
• Prof. Igor Tartalja
• Course: Programming Languages and Methods of
Programming
– (semester 5+6, 2 hours/week lecture + 2 hours/week
exercises)
– Fifth semester: Concepts of object-oriented software. C++
– Sixth semester: Java. Software portability. Bytecode and
JVM. Compilers. Classes and objects. Access control.
Constructors. Methods. Parameters. Method overlapping.
Garbage collection.
13
Živana Komlenov: Existing programming teaching materials
DCSE, Faculty of Electrical
Engineering, Belgrade
– Nested classes and packages. Access rights. Packages.
Interfaces. Inheritance.
– Exceptions. Error detection. Throw command. Exception
handling. Try-catch-finally construction.
– GUI. Package AWT. Event handling.
– No homework, practical assignments, etc.
• Contributions:
– Many interesting Supporting Java examples from 'Exercises
for Programming Languages and Methods of Programming
Course' (in Serbian), Copyright 2001 by Laslo Kraus
– Written exams, some examples included in Short exercises
14
Živana Komlenov: Existing programming teaching materials
Chair of Computer Science,
Mathematical Faculty, Belgrade
• Prof. Dušan Tošić
• Course: Programming Languages
– (semester 5+6, 2 hours/week lecture + 2 hours/exercises)
– PROLOG; LISP (Scheme)
– Java. Compared to Smalltalk. Basic language elements.
Creating applications and applets in Java.
– Written exams
• Contributions:
– Some seminar assignments – games. Ideal for Longer examples.
15
Živana Komlenov: Existing programming teaching materials
CSED, Faculty of Automatics
and Computers, Timisoara
• Prof. Ioan Jurca
• Course: Object-Oriented Programming
– (semester 4, 2 hours/week lecture + 2 hours/week lab)
– Fundamental concepts of object-oriented programming. Classes
and objects: class structure, fields, methods, object creation.
– Extending classes, type compatibility, abstract classes.
– Interfaces: declaration, extension, working with interfaces.
Nested classes and interfaces: static nested types, inner classes.
– Exceptions: creating exception types, throw and throws; try,
catch, finally.
16
Živana Komlenov: Existing programming teaching materials
CSED, Faculty of Automatics
and Computers, Timisoara
– Packages: package naming; relation with the directory structure;
short overview of standard Java packages.
– Concurrent programming (threads): creating threads; thread
synchronization.
– Graphical User Interfaces: the event model, the AWT package.
• Contributions:
– Version in Romanian of the material students should use to
prepare their lab assignments. There are 12 lessons, each
consisting an explanation of a set of concepts, intersperced with
Java programs (or program fragments) and ending with the text
of one or more assignments (translation in progress).
17
Živana Komlenov: Existing programming teaching materials
Collected examples
• Examples used at our member universities,
divided as suggested:
– Supporting Java examples
– Short exercises
– Longer examples
18
Živana Komlenov: Existing programming teaching materials
Supporting Java examples
• Nice combination of examples from Berlin, Novi Sad
and Belgrade (FEE).
• Mainly material used in classical exercises or lectures.
Partly suitable for lecture slides, but on the other hand
there are examples complex enough to be used as part
of any sort of exercises.
• All examples have been translated to English and sorted
by topics they cover.
19
Živana Komlenov: Existing programming teaching materials
Supporting Java examples
–
–
–
–
–
–
–
–
–
20
Intro
Keyboard
Math
Recursion
Array
• Search
• Sort
String
File
Object
Inheritance
–
–
–
–
–
–
–
–
–
–
Time
Interface
Collection
List
Stack
Queue
Error
Exception
Hash
Package
• Plane
–
–
–
–
–
–
• Figures
• LinAlgebra
Tree
Maze
Applet
GUI
Synchronization
• Primitives
• Graphics
• Examples
Supermarket
Živana Komlenov: Existing programming teaching materials
Short exercises
• Written exams
– Several solved examples from Novi Sad and Belgrade
(FEE), as well as texts of some more assignments (much
more of those are still in Serbian, stored as additional
material).
• Lab exercises
– Examples from Novi Sad, used in fall 2003/2004 when
Programming languages course was completely taught for
the first time since the new curriculum had been adopted.
Some student solutions are enclosed.
21
Živana Komlenov: Existing programming teaching materials
Short exercises
• Practical assignments
– Mainly examples concerning thread synchronization, again
from Novi Sad.
– Those assignments were given to students in fall 2003/2004
when Operating systems I course was completely taught for
the first time since the new curriculum had been adopted.
– They represent typical final assignments, with time limits of
approximately 3-4 weeks.
– There are some very good student solutions and just
formulations of other possible assignments.
22
Živana Komlenov: Existing programming teaching materials
Lab exercise example
DMI, Faculty of Science, University of Novi Sad, Serbia and Montenegro
Programming Languages, Prof. Mirjana Ivanović
Lab exercises: Nataša Ibrajter, 2003/2004
Student: Miroslav Nadj
Program Parents should read data from file 'Names.txt'. This file contains
names of children available for adoption. After reading all names, program
should create instances of Child objects, store them in an array and then allow
user to enter sex and age for each child.
Future parents should be able to set preferred characteristics and as a reply get
a list of children sorted by how well they match parents' criteria.
Class Child should contain following fields: name, sex, age.
Field priority while searching: name, sex, age.
Sex entering: m - male, f - female.
23
Živana Komlenov: Existing programming teaching materials
Lab exercise example
import java.io.*;
public void putPoints(int points) {
this.points = points;
}
public int getPoints() {
return points;
}
public String getSex() {
return sex;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
class Child {
private String name, sex;
private int age, points;
public Child(String name) {
this.name = name;
sex = "f";
age = 0;
points = 0;
}
public void putAge(int age) {
this.age = age;
}
public void putSex(String sex) {
this.sex = sex;
}
24
}
Živana Komlenov: Existing programming teaching materials
Lab exercise example
public class Parents {
public static void printData(Child[] array) {
for (int i = 0; i < array.length; i++) {
System.out.println(" " + (i+1) + ". " + array[i].getName() + " " +
array[i].getSex() + " " + array[i].getAge() + " " +
array[i].getPoints());
}
System.out.println();
}
public static void scoreChildren(Child[] array, String nameWish,
String sexWish, int ageWish) {
int points = 0, difference = 0;
for (int i = 0; i < array.length; i++) {
if ((array[i].getName()).compareTo(nameWish) != 0) {
points += Math.abs(array[i].getName().length() - nameWish.length())*4;
}
25
Živana Komlenov: Existing programming teaching materials
Lab exercise example
if ((array[i].getSex()).compareTo(sexWish) != 0) {
points += 200;
}
if (array[i].getAge() != ageWish) {
difference = Math.abs(ageWish - array[i].getAge());
points += difference*2;
}
array[i].putPoints(points);
points = 0;
}
}
public static Child[] sortChildren(Child[] array) {
Child[] tempArray = array;
for (int i = 0; i < array.length-1; i++) {
for (int j = i+1; j < array.length; j++) {
if (tempArray[i].getPoints() > tempArray[j].getPoints()) {
26
Živana Komlenov: Existing programming teaching materials
Lab exercise example
Child temp = tempArray[i];
tempArray[i] = tempArray[j];
tempArray[j] = temp;
}
else if (((tempArray[i].getName()).compareTo(tempArray[j].getName()) > 0)
&& (tempArray[i].getPoints() == tempArray[j].getPoints() )) {
Child temp = tempArray[i];
tempArray[i] = tempArray[j];
tempArray[j] = temp;
}
}
}
return tempArray;
}
public static void main(String[] args) throws IOException {
BufferedReader file = new BufferedReader(new InputStreamReader(
new FileInputStream("Names.txt")));
27
Živana Komlenov: Existing programming teaching materials
Lab exercise example
String[] names = new String[10];
String name = file.readLine();
int n = 0;
while (name != null) {
names[n] = name;
name = file.readLine();
n++;
}
BufferedReader input = new BufferedReader(
new InputStreamReader(System.in));
Child[] children = new Child[n];
System.out.println();
System.out.println(" --- Enter sex and age ---");
System.out.println();
for (int i = 0; i < n; i++) {
children[i] = new Child(names[i]);
System.out.println("Name: " + children[i].getName());
System.out.print("Sex (m - male; f - female): ");
28
Živana Komlenov: Existing programming teaching materials
Lab exercise example
children[i].putSex(input.readLine());
System.out.print("Age: ");
children[i].putAge(Integer.parseInt(input.readLine()));
System.out.println();
}
System.out.println(" --- Enter search criteria --- ");
System.out.print("Name: ");
String nameWish = input.readLine();
System.out.print("Sex: ");
String sexWish = input.readLine();
System.out.print("Age: ");
int ageWish = Integer.parseInt(input.readLine());
scoreChildren(children, nameWish, sexWish, ageWish);
Child[] tempArray = sortChildren(children);
System.out.println(" --- Children matching the criteria --- ");
printData(tempArray);
}
}
29
Živana Komlenov: Existing programming teaching materials
Longer examples
• Examples from Novi Sad
– Practical assignments for students passing from old
curriculum to the new one, that had not taken Programming
languages written exam before that, so now they are required
to do some practical work instead.
– Enclosed are several student solutions and just formulations
of other possible assignments.
• Examples from Belgrade (Mathematical Faculty)
– Seminar assignments - different kinds of games, with student
solutions (some of them quite good).
30
Živana Komlenov: Existing programming teaching materials
Additional materials
• Sources:
– Examples from other courses at member
universities that include more complex Java
assignments (currently in Serbian)
– Examples from representative Java textbooks
31
Živana Komlenov: Existing programming teaching materials
DCSE, Faculty of Electrical
Engineering, Belgrade
• Prof. Igor Tartalja
• Course: Object-Oriented Software
– (semester 9, 2 hours/week lecture + 2 hours/week exercises)
– Combining UML modelling and Java implementations
• Contributions (in Serbian):
– Examples from 'Exercises for Object-Oriented Software
Course' (in Serbian), Copyright 2002 by Laslo Kraus
– Relatively complex practical assignments
– Written exams
32
Živana Komlenov: Existing programming teaching materials
DMI, Faculty of Science,
Novi Sad
• Prof. Miloš Racković
• Course: Artificial Intelligence I
– (semester 5, 2 hours/week lecture + 2 hours/week exercises +
1 hours/week lab)
– Basics of artificial intelligence. Knowledge representation.
Searching as a problem solving method. Strategies. Heuristic
procedures. Expert systems.
– Exam: practical + oral
• Contributions (in Serbian):
– Relatively complex practical assignments
33
Živana Komlenov: Existing programming teaching materials
Java textbooks
• Potentially useful Java textbooks, chosen on account of the
variety of neat examples included. Full source code of those has
been collected as additional material.
– ‘Java Software Solutions’, 4th Edition
– ‘Thinking in Java’, 3rd Edition
– ‘Java Gently’, 3rd Edition
– ‘Teach Yourself Java 2 in 21 Days’, 4th Edition
– ‘Effective Java’
– ‘Java Cookbook’
– ‘Java Examples in a Nutshell’, 3rd Edition
34
Živana Komlenov: Existing programming teaching materials
Java Software Solutions
• ‘Java Software Solutions’, 4th
Edition
– John Lewis and William Loftus
– William Loftus is a serial
entrepreneur and author.
– John Lewis is an Associate
Professor of Department of
Computing Sciences, Villanova
University, PA, USA
– Teaching - Fall 2004: CSC 1051 Data Structures and Algorithms I
35
Živana Komlenov: Existing programming teaching materials
Thinking in Java
• ‘Thinking in Java’, 3rd Edition
– Free electronic book
– Published by Prentice-Hall,
December 2002
– Bruce Eckel – his company
provides public and private
training and consulting services.
– He has published over 150 articles
and several books.
– Parts of this book are already used
for exercises in Novi Sad.
36
Živana Komlenov: Existing programming teaching materials
Java Gently
• ‘Java Gently’, 3rd Edition
– Addison-Wesley, 2001.
– Judith Bishop, University of
Pretoria, South Africa
– Based on courses given in Java since
1996, and on courses in other
languages presented to first year
science and engineering students
since 1980.
– Over 80 fully worked examples,
together with test data and output.
37
Živana Komlenov: Existing programming teaching materials
Teach Yourself Java 2
in 21 Days
• ‘Teach Yourself Java 2 in 21
Days’, 4th Edition
– Laura Lemay and Rogers
Cadenhead
– Sams, 2004.
– Clear and personable writing
– Extensive use of examples
– Logical and complete
organization
– Covers the latest developments
in Java
38
Živana Komlenov: Existing programming teaching materials
Effective Java
• ‘Effective Java’ Programming
Language Guide
– Joshua Bloch, Senior Staff Engineer
at Sun Microsystems, Inc., in the
Core Java Platform Group.
– Designed and implemented the
award-winning Java Collections
Framework, the java.math package.
– Here he shares 57 "nuggets“ - rules
and code examples showing what
works, what doesn't, and how to use
the language libraries to best effect.
39
Živana Komlenov: Existing programming teaching materials
Java Cookbook
• ‘Java Cookbook’
–
–
–
–
40
Solutions and Examples for Java
Developers
Ian F. Darwin
O'Reilly, 2001
Comprehensive collection of
problems, solutions, and practical
examples.
Short, focused pieces of code that are
easy to incorporate into other
programs. Focus on things that are
useful, tricky, or both.
Živana Komlenov: Existing programming teaching materials
Java Examples in a Nutshell
• ‘Java Examples in a Nutshell’, 3rd
Edition
– David Flanagan
– O'Reilly, 2004
– Entire book of real-world Java
programming examples to learn from.
– Covers Java 1.4 and contains 193
complete, practical examples: over
21,900 lines of densely commented,
professionally written Java code,
covering 20 distinct client-side and
server-side APIs.
41
Živana Komlenov: Existing programming teaching materials
Conclusions
• Comparison of example difficulty
– Different approach for first and second (or third) year
courses dictates differences in example choice and dfficulty.
– We should try to make the best of both views and allow
lecturers to use those parts of joint course material they find
suitable for their students.
• Teaching programming vs teaching Java
– For a first-year course, it is no longer sufficient to just teach
a language.
– In addition to explaining syntax and the construction of a
well-formed program, a modern Java course has to include
techniques for problem solving.
42
Živana Komlenov: Existing programming teaching materials
Statistics - current state of
gathered material
• Supporting Java examples
– All collected examples translated and sorted.
• Short exercises
– Written exams - Just several solved examples translated and included (all
available solutions). Texts of a lot of other assignments are mainly still in
Serbian.
– Lab exercises - Texts of all examples included. Only a few student solutions
enclosed (all of those found).
– Practical assignments – Again just several full examples collected.
Formulations of other possible assignments are partly still in Serbian.
• Longer examples
– All collected examples translated and sorted.
– 30% just as formulations of possible assignments.
43
Živana Komlenov: Existing programming teaching materials
Future work
• Work done so far is just a basis for a complete pool of
assignments. It gives us a good starting point, still leaving space
for much more effort and coordinated example collecting and
sorting.
• Only when collected examples start being combined and used,
we shall be able to define the most appropriate division strategy
and ideas for future work.
• Tasks:
– Including all sorts of additional examples.
– Precise programs of lab exercises and practical assignments
for other types of exercises, seminars, etc.
– English versions of all available assignments.
– Local versions later.
44
Živana Komlenov: Existing programming teaching materials
Download