Page 331 - Introduction to Programming with Java: A Problem Solving Approach
P. 331
We’ll illustrate coding-style conventions by referring to the Student program in Figure 8.1 and Figures 8.2a and 8.2b. This program is a modified version of the Student program at the back of the “Java Coding-Style Conventions” appendix.
Prologue Section
Note the boxed text at the tops of Figures 8.1 and 8.2a. They’re called prologues. Include a prologue section at the top of each file. The prologue contains these things in this order:
• lineofasterisks
• filename
• programmer name(s)
• blank line with one asterisk • description
• lineofasterisks
• blank line
Enclose the prologue in a /*. . .*/ comment, and to make the prologue look like a box, insert an asterisk and a space in front of the filename, programmer name, blank line, and description lines.
Named Constants and Instance Variables
Provide a blank line, a line of asterisks, and another blank line after the block of statements that declares and/or initializes all named constants and instance variables.
Apago PDF Enhancer
8.2 Coding-Style Conventions 297
/*******************************************************
*
StudentDriver.java
Dean & Dean
This class acts as a driver for the Student class.
********************************************************/
*
*
*
public class StudentDriver
{
}
// end class StudentDriver
public static void main(String[] args)
{
}
Student s1; // first student
Student s2; // second student
s1 = new Student();
s1.setFirst("Adeeb");
s1.setLast("Jarrah");
s2 = new Student("Heejoo", "Chun");
s2.printFullName();
// end main
Figure 8.1
StudentDriver class