What’s New in
Computer Science Education?
A Report on the
2005 ACM/SIGCSE Meeting
ACM/SIGCSE Meeting
• Where: St. Louis
• When: February 23-26, 2005
• Papers:
http://db.grinnell.edu/sigcse/sigcse2005/Program/program.asp
Major Themes
• Women in computing
• Image processing
• Writing game software
• Robotics
• Approaches to introductory
programming
Women and Computing
• A panel on experiences at different
colleges
• A session with four papers
• A keynote address by Maria Klawe,
past president of the ACM and
Dean of Engineering at Princeton
Image Processing
• In secondary school (Scion)
• For training teachers in Georgia
(Georgia Tech)
• In CS1 (Swarthmore)
Writing Game Software
• Games and CS education
• A concentration within the CS
curriculum
Robotics
• A session with four papers
• A workshop on LEGO Mindstorms
Introductory Programming
• Debate on objects early
• Rigor (algorithms)-first approach
• The use of environments, microworlds,
and toolkits
• The ACM Java Task Force
The ACM Java Task Force
• Created in 2004 to study problems with
teaching Java in intro courses
• Solicited toolkits as proposed solutions or
learning aides
• Published a draft of a report on the problems
and a tentative synthesis or distillation of
solutions
Problems With Teaching
Java
• High-level issues
– Scale
– Instability
– Execution speed
– Textbooks and environments
Problems With Teaching
Java
• Language issues
–
–
–
–
–
–
–
–
public static void main(String[] args)
Exceptions
Separation of interface and implementation
Wrapper classes
Parameterized classes
Enumerated types
Coding preconditions
Iterator syntax
Problems With Teaching
Java
• API issues
– Simple input mechanism
– Graphics model
– GUI model
– Event model
Solutions
• Packages for
– console I/O
– modal dialog I/O
– graphics
• A program package for writing
applications/applets using these
three I/O styles
Console I/O
• The package acm.io includes an
IOConsole class that supports
input and output of basic data
types
• It can be used with or without the
acm.program package
Example with IOConsole
import acm.io.*;
import java.awt.*;
import javax.swing.*;
public class CircleArea{
public static void main(String[] args){
JFrame frame = new JFrame();
IOConsole console = new IOConsole();
frame.getContentPane().add("Center", console);
frame.setSize(500, 300);
frame.setVisible(true);
console.println("This program displays the area of a circle");
int radius = console.readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
console.println("The area is " + area);
}
}
Example with IODialog
import acm.io.*;
import java.awt.*;
import javax.swing.*;
public class CircleArea{
public static void main(String[] args){
IODialog dialog = new IODialog();
dialog.println("This program displays the area of a circle");
int radius = dialog.readInt("Enter the radius");
double area = radius * radius * Math.PI;
dialog.println("The area is " + area);
}
}
Graphics
• The package acm.graphics
includes
– double-valued coordinates
– A hierarchy of shapes that reflect the
options available in the Graphics
class but that maintain their state
– A canvas that refreshes automatically
acm.graphics Hierarchy
GCanvas
GPoint
GDimension
GCompound
GArc GImage
GCanvasMenuBar
GRectangle
GTurtle
GObject
GLabel
GLine
GPPen
GOval GRect GPolygon
All GObjects accept mouse listeners
Example With Graphics
import acm.graphics.*;
import java.awt.*;
import javax.swing.*;
public class HelloWorld extends JFrame {
public HelloWorld(){
GCanvas gc = new GCanvas();
GLabel label = new GLabel("Hello world!");
label.setFont("Helvetica-bold-72");
label.setColor(Color.red);
gc.add(label, 50, 100);
getContentPane().add("Center", gc);
setSize(500, 300);
}
public static void main(String[] args){
new HelloWorld().setVisible(true);
}
}
The Output
acm.program Package
• Encapsulates the main method so it’s not a
distraction
• Can run a program as an application or an
applet with no changes
• Backwards compatible with JDK 1.1 for older
browsers
• Includes standard menus for printing an
interaction and accepting input from files
acm.program Hierarchy
java.applet.Applet
Program
ConsoleProgram
DialogProgram
GraphicsProgram
Example with IOConsole
import acm.io.*;
import java.awt.*;
import javax.swing.*;
public class CircleArea{
public static void main(String[] args){
JFrame frame = new JFrame();
IOConsole console = new IOConsole();
frame.getContentPane().add("Center", console);
frame.setSize(500, 300);
frame.setVisible(true);
console.println("This program displays the area of a circle");
int radius = console.readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
console.println("The area is " + area);
}
}
Example with Program
import acm.program.*;
public class CircleArea extends Program{
public static void main(String[] args){
new CircleArea().start(args);
}
public void run(){
println("This program displays the area of a circle");
int radius = readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
println("The area is " + area);
}
}
Uses the host system’s terminal
Example with Program
import acm.program.*;
public class CircleArea extends Program{
public void run(){
println("This program displays the area of a circle");
int radius = readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
println("The area is " + area);
}
}
Omit main method to simplify
Example with
ConsoleProgram
import acm.program.*;
public class CircleArea extends ConsoleProgram{
public void run(){
println("This program displays the area of a circle");
int radius = readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
println("The area is " + area);
}
}
Extend ConsoleProgram to get a console window
with File and Edit menus
Example with
DialogProgram
import acm.program.*;
public class CircleArea extends DialogProgram{
public void run(){
println("This program displays the area of a circle");
int radius = readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
println("The area is " + area);
}
}
Extend DialogProgram to get I/O with modal
dialogs
Make It More Oopy-Like
import acm.program.*;
public class CircleArea extends DialogProgram{
public void run(){
IOModel io = this.getConsole();
io.println("This program displays the area of a circle");
int radius = io.readInt("Enter the radius: ");
double area = radius * radius * Math.PI;
io.println("The area is " + area);
}
}
Both IOConsole and IODialog implement IOModel
Example With Graphics
import acm.graphics.*;
import java.awt.*;
import javax.swing.*;
public class HelloWorld extends JFrame{
public HelloWorld(){
GCanvas gc = new GCanvas();
GLabel label = new GLabel("Hello world!");
label.setFont("Helvetica-bold-72");
label.setColor(Color.red);
gc.add(label, 50, 100);
getContentPane().add("Center", gc);
setSize(500, 300);
}
public static void main(String[] args){
new HelloWorld().setVisible(true);
}
}
Example With
GraphicsProgram
import acm.graphics.*;
import acm.program.*;
public class HelloWorld extends GraphicsProgram{
public void run(){
GLabel label = new GLabel("Hello world!");
label.setFont("Helvetica-bold-72");
label.setColor(RED);
double x = (getWidth() - label.getWidth()) / 2;
double y = (getHeight() - label.getAscent()) / 2;
add(label, x, y);
}
}
Turtle Graphics Example
import acm.graphics.*;
import acm.program.*;
public class DrawTurtleFlower extends GraphicsProgram{
public void run(){
GTurtle turtle = new GTurtle();
add(turtle, getWidth() / 2, getHeight() / 2);
turtle.penDown();
for (int i = 0; i < 36; i++){
for (int j = 0; j < 4; j++){
turtle.forward(100);
turtle.left(90);
}
turtle.left(10);
}
}
}
Can be decomposed with methods or by subclassing
Ouput
GUI Programs?
• The task force could not agree on
a common framework
• Recommends using a toolkit like
BreezySwing
• But it would be nice to have a
standard GUIProgram class
Descargar

Customer Request - Washington and Lee University