owned this note
owned this note
Published
Linked with GitHub
# Java Review Components
## the Problem
### Less Practice, More Sandboxes
In contrast to the Python course, both Quinton and I felt the Java course lacked opportunities to practice java coding in-depth. The Python course contains several lessons that are essentially supervised sandbox sessions - in which a student builds a program entirely from scratch and gets feedback. These in-depth practices are seperate from the quizzes and coding tests.
I wish I could think of a better term than "practice", because yes both courses contain *practice* in each of the components for each lesson. These '*practices*' are really more like example problems during a lecture, you are shown how to do it and there is hand-holding. What we feel is missing are the components that feel like "homework" - opportunities to implement what we learned during the lesson and recieve constructive feedback.
Aside from missing entire lessons dedicated to practice (like the Python course's *A Day at the Supermarket* or *Student Becomes the Teacher* lessons), the Java course is also skimpy on review practice at the end of each component. I think that these two facts add together, generating the feeling that there is just less coding practice and less confidence in one's java ability.
In an attempt to clarify what I mean, let us liken the two Codecademy courses to actual college class. The "practice" in the components of each lesson is like the few example problems you see during a lecture. Sure they may count as practice, but your teacher walks you threw how to solve them and they tend to be pretty easy. In contrast, the practice in the review components tends to be like the practice problems your teacher assigns you to do before the next lecture, where they will give you the answer. And the projects (w/o feedback, similar to the RPS midterm project)and the lessons entirely devoted to practice (w/ feedback, only in Python course) are similar to the homework.
If you only do the in-lecture example problems, you don't get the same understanding of the material as you would completeing the out-of-lecture practice problems and homework. I hope this analogy helped.
#### Ratio of Sandboxes
Technically the Python course also includes some sandboxes. When I went through the basic **Python 2** course, I counted 3-4 lessons that ended with these review sandboxes. Although, this was true mainly for the 'practice-lessons'- PygLatin, A Day at the Supermarket, Battleship, etc. This was out of 20 lessons.
In contrast 10/16 of the Java course lessons ended with a sandbox review. So the Java course has two things counting against it: (1) it lacks the so-called 'practice-lessons' I mentioned that are in the Python course which are like homework, and (2) at least half of the review components are less like practice problems and more like sandboxes. As we have discussed in team meeting, these sandboxes are very open-ended. Codecademy simply tells students to "play around" with the code, which is provided in full. This means subjects would get less feedback on this practice, if they even do it at all. I'm sure that some people will skip past these components entirely.
### Potential Solutions
While this might be something we just have to accept, there are a couple of potential solutions:
1. We could force the subjects to "play around" in the sandbox for a set time.
2. We could have the subjects complete the projects (which don't have feedback) associated with each lesson.
3. We could costruct actual practice steps for the subject to complete in the sandbox.
*The rest of this note explores the third option.*
## Alternative Practice for Java Review (3rd option)
To explore the practicality of developing specific practice problems for each of the 10/16 sandbox review components in the Java course, I did so for the first lesson where a sandbox occurs. That is the fourth lesson, named **Java: Intro to Classes**.
### Existing Practice
The "practice" for the review component at the end of the **Java: Intro to Classes** lesson on Codecademy is a perfect example of the open-ended "sandboxes" included in the Java course. Compared to other review components, a student is simply prompted to "play around" with the code. There is no constructive feedback or guarantee that the student tries messing with the code.
Here are the *existing* instructions for the **Classes: Review** component at the end of lesson 4, **Java: Intro to Classes**.

In addition, students are given the following code in the text window.
``` java
public class Dog {
String breed;
boolean hasOwner;
int age;
public Dog(String dogBreed, boolean dogOwned, int dogYears) {
System.out.println("Constructor invoked!");
breed = dogBreed;
hasOwner = dogOwned;
age = dogYears;
}
public static void main(String[] args) {
System.out.println("Main method started");
Dog fido = new Dog("poodle", false, 4);
Dog nunzio = new Dog("shiba inu", true, 12);
boolean isFidoOlder = fido.age > nunzio.age;
int totalDogYears = nunzio.age + fido.age;
System.out.println("Two dogs created: a " + fido.breed + " and a " + nunzio.breed);
System.out.println("The statement that fido is an older dog is: " + isFidoOlder);
System.out.println("The total age of the dogs is: " + totalDogYears);
System.out.println("Main method finished");
}
}
```
This is the complete code for the program. Students are able to mess around in the "sandbox" for as long as they want before moving onto the associated quiz.
### Concerns
* Not sure how to standardize the time participants will spend completeing this review. I want it to be similar to the average time in the Python course, but I really can't control that.
* The example `Dog` class that Codecademy gives users to sandbox with is actually used in the lesson's hints. Take the hints for components 5 and 7 as examples:


I raise this point because I think it could be a *pro* and a *con*. On the plus side, this echos the "building" of code throughout the lesson and making sure the student feels comfortable with the practice. However, it could also introduce bias since many participants many not look at the hints, if any.
This will defiantely be something that we need to discuss as a team, but anticipating the issue I have workshoped a solution. Below, I created actual practice steps for the Classes:Review component. One example uses the same `Dog` class as Codecademy originally included, and the other is one I generated called `Student`.
## Dog Class Example
### Code Provided to Subjects:
We want the subjects to start from a bare structure, so have them clear the code currently in the text window and then copy-in the following. Note this also allows us to delete the extra parts of the existing code that we don't want the subjects to focus on.
```java=
public class Dog {
// instance fields
String breed;
// constructor method
public Dog(String dogBreed) {
breed = dogBreed;
}
// main method
public static void main(String[] args) {
// System.out.println("In dog years, Kintsugi is " + kintsugiActualAge + " and Bella is " + bellaActualAge);
}
}
```
*I modeled this starting code off of the simplified version of the program since it was already provided and I want subjects to focus on new tasks rather than copying what is already there.*
### Instructions:
In addition to the dog's breed, we want to keep track of the dog's age and color.
1. Create two new instance fields for the `Dog` class.
* `age` of type `int`
* and `color` of type `String`.
2. Update the parameter list of the constructor method to include an `int` variable called `dogAge` and a `String` variable called `coatColor`.
3. Assign the new parameter values to the proper instance fields.
4. Inside the `main()` method, create two instances of the `Dog` class for `kintsugi` and `bella`.
`kintsugi` is a `1` year old golden `yellow` `retriever`
and `bella` is an`8` year old `brown` `lab`.
4. We want to know how many years old each dog is in dog years. Create two new variables:
`int kintsugiActualAge` and `int bellaActualAge`
Assign each variable the age of each dog multiplied by 7, because one human year equates to 7 dog years.
5. Uncomment the print statement to print each dog's actual age to the terminal.
6. Finally, using `System.out.println()` print each dog's breed to the terminal.
### Correct Code:
```java=
public class Dog {
// instance fields
String breed;
int age;
String color;
// constructor method
public Dog(String dogBreed, int dogAge, String coatColor) {
breed = dogBreed;
age = dogAge;
color = coatColor;
}
// main method
public static void main(String[] args) {
Dog kintsugi = new Dog("retriever", 1, "yellow");
Dog bella = new Dog("lab", 8, "brown");
int kintsugiActualAge = kintsugi.age * 7;
int bellaActualAge = bella.age * 7;
System.out.println("In dog years, Kintsugi is " + kintsugiActualAge + " and Bella is " + bellaActualAge);
System.out.println(kintsugi.breed);
System.out.println(bella.breed);
}
}
```
### Correct Output:
```
In dog years, Kintsugi is 7 and Bella is 56
retriever
lab
```
## Student Class Example
### Code Provided to Subjects:
To have the subject's practice with a different class entirely, we have to set up a new file on Codecademy. This is necessary for Codecademy to compile the code and is, fortunately, pretty simple.
At the top of the text window, click on the file icon. Then click the *add file* icon on the right. Type **Student.java** in the *file name* field, then click the green plus button.
Have the subject paste the following code into the text window to get things started. **Make sure they paste the code and work in the correct file!**
```java=
public class Student{
// instance fields
// constructor method
public Student(){
}
// main method
public static void main(String[] args){
}
}
```
### Instructions:
We want to create a class named `Student` that keeps track of the grade level, GPA, and scholarship status of each student at our school.
1. To begin, declare three instance fields for `Student`.
* `grade` of type `int`
* `gpa` of type `double`
* and `onScholarship` of type `boolean`.
2. Pass the following parameters to the `Student()` constructor.
* an `int` parameter `gradeLevel`,
* a `double` parameter `studentGPA`,
* and a `boolean` parameter `scholarship`.
3. Inside the constructor, assign the parameter values to the appropriate instance fields. Remember that the order of the parameters matters!
4. Now inside the `main()` method, we want to create an instance of `Student` for each of our students. Create instances for:
* `iris`, who is in grade `4`, has a gpa of `3.78`, and is *not* on scholarship.
* `malayka`, who is in grade `5`, has a gpa of `3.08`, and *is* on a scholarship.
* and `teddy`, who is in grade `6`, has a gpa of `2.89`, and is also *not* on scholarship.
5. Finally, we want to know the average GPA for our school. Inside of main(), create a new variable of type `double` called `avgGPA`.
Set `avgGPA` equal to the sum of all our student's GPAs divided by three.
```avgGPA = (<iris' gpa> + <malayka's gpa> + <teddy's gpa>)/3```
where ```<iris' gpa>``` is replaced with ```iris.gpa``` and ```<malayka's gpa>``` and ```<teddy's gpa>``` replaced simarily.
6. Print the following statement to the terminal.
```System.out.println("Our school's average GPA is: " + avgGPA);```
### Correct Code:
```java=
public class Student{
// instance fields
int grade;
double gpa;
boolean onScholarship;
// constructor method
public Student(int gradeLevel, double studentGPA, boolean scholarship){
grade = gradeLevel;
gpa = studentGPA;
onScholarship = scholarship;
}
// main method
public static void main(String[] args){
Student iris = new Student(4, 3.78, false);
Student malakya = new Student(5, 3.08, true);
Student teddy = new Student(6, 2.89, false);
double avgGPA = (iris.gpa + teddy.gpa + malakya.gpa)/3;
System.out.println("Our school's average GPA is: " + avgGPA);
}
}
```
### Correct Output:
```
Our school's average GPA is: 3.25
```