CODE SAMPLES

Robust, object-oriented code that performs a single function is easy to copy and modify.  It helps to have very small snippets  to modify when building to specification or to an acceptable level of quality.

Most of the code samples on this Web site that were full-fledged applications have been removed, due to the age of the software or hardware that was required. The snippets that are intended for beginning programmers small enough to re-compile into new editions of languages. They are located in the Student-Oriented Code Samples section.


STUDENT-ORIENTED CODE SAMPLES

Teaching samples are not always the best code. because they are designed to illustrate one and only one point based on the students' current knowledge.  For every snippet posted on a site, a better implementation is in the next chapter, in the next book, or on the next Web page.   Better code samples are available on the Internet that have been authored by developers with a business audience, to illustrate how to use modules within an API or SDK. Some of my favorites are included in the Links page.



Two-Dimensional Arrays in Java

This program is a rudimentary exploration of 2-dimensional arrays.  It also introduces the concept of multiple windows, which is common for Java programs.  It requires a class named DrawingPanel.java, which can be downloaded from the site named http://www.buildingjavaprograms.com/supplements.shtml. The site accompanies the textbook "Building Java Programs", which is the introductory programming textbook  at UW Seattle.

After the students explore jFrame and jPanel objects, the ArayMax2 program can be written to extend those classes for a sleeker look.

araymax2.java
File Size: 16 kb
File Type: java
Download File



2D Graphical Arrays in Java

This program explores multiple windows for Java programs; it was intended to be an extension of the araymax program, but the architecture imposed by the Java Virtual Machine meant a complete rewrite.   The new program uses JFrame and JPanel objects to draw shapes in a 2-dimensional array on a screen.

The rewrite no longer requires the DrawPanel object; instead, each shape that can be drawn on the screen is its own class, and it coordinates with the JPanel object extension.

framemax.zip
File Size: 8 kb
File Type: zip
Download File

Some presentations include images that were included with purchased software.