Jump to page content Jump to navigation

College Board

AP Central

AP Exam Reader
AP Annual Conference - Save the Date
Siemens Awards for Advanced Placement

Print Page
Home > AP Courses and Exams > Course Home Pages > Java as a Pre-AP Strategy in Computer Science, Part III

Java as a Pre-AP Strategy in Computer Science, Part III

by James Aldridge, Ph.D.
Fort Worth Country Day School
Fort Worth, Texas

Quarter I: Basics
Quarter II: Introduction to Data Structures and Small Applications
Quarter III: Larger Applications
Quarter IV: Special Topics

This is Part III in a series of articles designed to take a computer science teacher in the Pre-AP years through the more difficult and confusing first components of teaching computer science in Java. In Part III we discuss the design of a typical, yearlong course. Additional articles will discuss the role of lectures and lab work, the integration of student projects into the course, and the evaluation of student assignments and projects.

It is difficult to generalize about a suitable yearlong course design. Different types of schools and different collections of students will dictate course variations. However, I think it's useful to discuss a general course design from which such variations can depart as appropriate. Certainly for the beginning Java teacher, such a design would serve as a baseline for modification.

Any approach to Java has to recognize the essential object-oriented nature of the language and its emphasis on encapsulated modules (classes) of code. I feel that it is especially important for students with some introduction to programming in a less object-oriented language to quickly gain an understanding of and an appreciation for the strength of object-oriented design.

At my school, we operate on a quarter system, with nine weeks per quarter, and each class meets for 45 minutes a day, five days a week. The timing in this article assumes this sort of class structure. While this would in theory provide 180 class days, the reality is that we have about 160 class days of actual instruction time. I suspect this is not an uncommon scenario.

In teaching programming, it is especially difficult to sequence the presentation. Do you present the idea of user-defined types before primitive data types, operators, and control structures, or do you delay the higher-level discussions? An attempt must be made to lay things out as needed, yet there are some issues that need to be introduced a bit all-at-once. The course outline that follows seeks to balance some of these various objectives. In some ways, it is more scope than sequence, as each year's unique student mix inevitably forces some alterations.

Quarter I: Basics
  • Computers and computing: I begin the year with a historical overview of computing and the general nature of computer hardware and software. We also discuss some of the ethical issues surrounding computer use, especially within the context of wide area networks such as the Internet.
  • Introduction to the Java development cycle:
    • Writing source code: Here I introduce the use of a text editor (often TextPad) and, in our case, an IDE (JCreator). The general structure of *.java source files is introduced. As we develop early classes, I try to keep test classes implementing the main() method separate from our working classes. Indeed, even the Hello World application introduced in Part II can be cast as a general String display class exercised by its own, separate test class.
    • Compilation to metacode: The use of metacode to achieve a high degree of platform independence is discussed. The production of the *.class file is demonstrated.
    • Execution of metacode: Platform-specific Java virtual machines are explained. Here, metacode is used to generate native code.
    • Rewriting/debugging: In my introductory courses I avoid the use of a formal debugger environment. I think it does more to obscure than to clarify basic principles. This same argument can be made against the use of IDEs in general, and I think it's easy to dispense with their use in an introductory course in favor of a rather simple text editor. I do find keyword highlighting useful, and most programming text editors implement that. Students are introduced to the use of embedded calls to System.out.println() and other rudimentary forms of debugging. They suffice.
    • Console i/o: Java's support of console i/o is rudimentary. It is a GUI-oriented language. Calls to System.out.print() or System.out.println() are fine for console output much of the time, but console input is more problematic. Many people are making simple i/o classes available specifically for teaching. I recommend their use. See the AP Computer Science Electronic Discussion Group (EDG) for some excellent guidance.
    • Applications and applets: Java applications and applets are compared and contrasted. Students are often more interested in applets than I am. The Java3D API (which can be downloaded separately from Sun's Web site) provides a MainFrame class (com.sun.j3d.utils.applet.MainFrame) that permits applets to be displayed as applications. In any case, applets are fun, and they are especially appropriate in a Pre-AP class that does some Web authoring.
  • Introduction to object-orientation: Introduce the concept of user-defined types and require careful thinking about objects as an application is designed. The general guideline to think of object nouns as fields and object verbs as methods is helpful. It may be useful to have students begin to document their code using Sun's Javadoc facility. Personally, I find it not very useful for small applications, and it can, like IDEs, get in the way of more central issues. In any case, have students document their code briefly but effectively from the onset.
    • User-defined types: classes
      • Fields
      • Methods (including Object methods that should frequently be overridden, like the toString() method)
      • Public interface
        • Constructors
        • Other public methods
    • Reusability
    • Encapsulation
    • Data hiding
  • Primitive data types (and their wrapper classes): Many people feel that the existence of primitive data types in Java is contrary to the general principles of objected-oriented design. However, they're here, and we all use them. This is probably a good time to introduce the Java API class documentation. Students can study, for example, the documentation for class Integer to discover goodies like parseInt() and intValue(). I also usually introduce one-dimensional arrays here.
    • Integers
      • byte (class Byte)
      • short (class Short)
      • int (class Integer)
      • long (class Long)
    • Floating point numbers
      • float (class Float)
      • double (class Double)
    • Special
      • boolean (class Boolean)
      • char (class Character)
  • Operators
    • Assignment
      • =
      • +=, -=, *=, /=, %=
    • Increment and decrement
      • pre ++, pre --
      • post ++, post -
    • Grouping: ()
    • Unary +, -
    • Multiplication: *, /, %
    • Addition: +, -
    • Comparison: <, <=, >, >=, ==, !=
    • Boolean &, ^, |
    • Logical &&, ||
  • Control structures
    • if, if/else
    • while
    • for
    • switch
    • do/while
    • break, continue
  • Object-orientation details
    • Inheritance
    • Interfaces
    • Polymorphism
    • Static fields and methods
    • Java API documentation; a more extensive overview
Quarter II: Introduction to Data Structures and Small Applications
During the second quarter of the year, we study some basic data structures (arrays, lists, stacks, and queues), and we do a half-dozen small applications to exercise the language and gain some practice with class design. Whether or not you choose to do this sans GUI or choose to introduce GUIs early on or indeed at all is a matter of some considerable debate. Personally, I find event-driven GUIs fascinating, and I think that students like them as well. On the other hand, I wouldn't deal with them to the detriment of more fundamental concepts.

In any case, I introduce simple Swing GUIs pretty early on, and we cover the general concept of Java interfaces as we implement various listeners (especially ActionListener). I also introduce the Java2D API so that we can do some custom painting in conjunction with graphing applications. Through all of this, maintain a strict separation between graphical, view-related elements and nongraphical modeling elements. Nongraphical components should stand alone well.

There are many good choices for small applications: games, simulations (we've done pendulum motion and free fall, for example), database applications (biological inventory of a region), simple encryption/decryption schemes, ASCII graphics data displays, statistical analyses, and so forth.

This quarter allows students to consolidate their mastery of Java basics while tackling a variety of small-scale assignments.

Quarter III: Larger Applications
This quarter we do a cooperative project of fairly large scale. The careful design of class interfaces and project specifications is emphasized. Small groups of students are given responsibility for subsets of the project and for ultimate project integration. To facilitate testing, streams are introduced along with file i/o.

This quarter's work will be a major topic in the penultimate article of this series: the integration of student projects into the course.

Quarter IV: Special Topics
I have a lot of fun with this. We start with some basic networking, including a classwide chat system. Threads are introduced with an eye toward using at least the Timer class to facilitate some animation exercises. Some students work with Java2D, some with photographic image manipulation. Studies within the Java3D API are becoming increasingly popular as the instructor (!) becomes more familiar with this interesting tool. This year several students worked on an MP3 audio player. Networked gaming applications have also been popular.

Students leaving Pre-AP Java are well prepared for the more focused studies that comprise the AP Computer Science curricula. Most of my students go on to take AP CS AB in their senior year.


Please note: Some topics covered in this series of articles are not included in the defined curriculum. Refer to the current official AP CS Course Description for the topics that will be tested on the AP Exams.

James Aldridge, Ph.D., is a science and computer science teacher at Fort Worth Country Day School in Fort Worth, Texas. He has taught computer programming for 10 years and currently teaches AP Computer Science using Scheme, Java, and C++. James also teaches AP Chemistry and has special computer science interests in the area of real time data acquisition and control subsystem hardware and software design.






  ABOUT MY AP CENTRAL
    Course and Email Newsletter Preferences
  AP COURSES AND EXAMS
    Course Home Pages
    Course Descriptions
    The Course Audit
    Sample Syllabi
    Teachers' Resources
    Exam Calendar and Fees
    Exam Questions
    AP Credit Policy Information
  PRE-AP
    Teachers' Corner
    Publications
  AP COMMUNITY
    About Electronic Discussion Groups
    Become an AP Exam Reader

Back to top