Assistance with a straight-forward class design and styling
<p>I have the following two-part question I am struggling with for an informal (i.e. not graded) assessment. Trying to get it done asap so I can get the feedback before an upcoming assignment. </p>

<p>Massive thanks to anyone that can help!</p>

<p><strong>Part one</strong>
There are four important aspects of CODE TWO that make it better than CODE ONE. For each of these explain why CODE TWO is better in terms of one or more of: code re-use, data hiding, readability and maintainability.</p>

<p><strong>Part Two</strong>
The programmer of CODE TWO needs to incorporate a new requirement into her class design. The new requirement is that instance of no other class (except for the Student class) should be able to change the value of the courseCode instance variabale. Explain how you would implement this new requirement by making a slight change to CODE TWO's version of the class (without adding or deleting any methods). </p>

<p><strong>CODE ONE</strong></p>

<pre><code>    public class Student  
    {  
      public String courseCode;  
      public int studentID;  

      public Student(String aCourse, int idNumber)  
      {  
        courseCode = aCourse;  
        studentID = idNumber;  
      }  

      public void displayStudent ()  
      {  
        System.out.println("Course: " + courseCode);  
        System.out.println("Student ID: " + studentID);  
      }  
}  
</code></pre>

<p><strong>CODE TWO</strong></p>

<pre><code>    public class Student  
    {  
      private String courseCode;  
      private int studentID;  

      public Student(String aCourse, int idNumber)  
      {  
        this.courseCode = aCourse;  
        this.studentID = idNumber;  
      }  

      public String getCourseCode ()  
      {  
        return this.courseCode;  
      }  

      public int getStudentId ()  
      {  
        return this.studentID;  
      }  

      public void setCourseCode(String aCode)  
      {  
        this.courseCode = aCode;  
      }  

      public void displayStudent ()  
      {  
        System.out.println("Course: " + this.getCourseCode() );  
        System.out.println("Student ID: " + this.getStudentID() );  
      }  
  }  
</code></pre>

<p>Here is my answer so far:</p>

<p>*There are several aspects to CODE TWO that make it superior to CODE ONE.
The use of accessor methods in the code aids in code re-use. Accessor methods help facilitate the altering of a class or creating a subclass for use in different situations.</p>

<p>Data-hiding, is where an object can hold encapsulated data (the instance variables) which can only be accessed through a limited set of public methods. Although only a basic project, should the project become larger, the use of data-hiding will allow for more effeficient division of labour. Also, this use of data-hiding means that any work to be performed on classes can be isolated, allowing different programmers to work on different classes, only requiring certain public methods.</p>

<p>The use of method comments helps support the re-use of code as it will assist anyone looking at the code to understand how to use the method and what it should do. Therefore, it can be suggested that method comments improve the maintainability of the code as anybody maintain the code is able to understand how the method was intended to be used.</p>

<p>By adding new methods to the class, it makes the code easier to maintain as it re-uses methods that have already been developed and tested for that class.* </p>

<p>So if anyone has any feedback or answers, it would be greatly appreciated! Many thanks, and sorry for the long post!! Ali</p>
