|
|
|
|
146
|
|
146
|
|
147
|
|
147
|
|
148
|
-
|
148
|
-
|
149
|
-### Notice the Design Flaw - Odd Casting Issues
|
|
|
|
|
149
|
+# Notice the Design Flaw - Odd Casting Issues
|
150
|
* You may have noticed that the `findById`, and `hostLecture` methods require an intermediate [casting trick](https://stackoverflow.com/questions/5289393/casting-variables-in-java).
|
150
|
* You may have noticed that the `findById`, and `hostLecture` methods require an intermediate [casting trick](https://stackoverflow.com/questions/5289393/casting-variables-in-java).
|
151
|
* To remedy this issue, we can _generify_ the `People` class.
|
151
|
* To remedy this issue, we can _generify_ the `People` class.
|
152
|
|
152
|
|
|
|
|
|
157
|
* Modify the `getArray` method to ensure that it returns an object of type `E[]`.
|
157
|
* Modify the `getArray` method to ensure that it returns an object of type `E[]`.
|
158
|
* Modify the `findById` method to ensure that it returns an object of type `E`.
|
158
|
* Modify the `findById` method to ensure that it returns an object of type `E`.
|
159
|
|
159
|
|
160
|
-# Part 9.2 - Modify `People` subclasses
|
|
|
|
|
160
|
+### Part 9.2 - Modify `People` subclasses
|
161
|
* Modify the `Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
|
161
|
* Modify the `Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
|
162
|
* Modify the `Instructors` class signature to ensure that it is a subclass of `People` of parameterized type `Instructor`.
|
162
|
* Modify the `Instructors` class signature to ensure that it is a subclass of `People` of parameterized type `Instructor`.
|
163
|
|
163
|
|
164
|
-# Part 9.3 - Refactor `ZipCodeWilmington` class
|
|
|
|
|
164
|
+### Part 9.3 - Refactor `ZipCodeWilmington` class
|
165
|
* Refactor the `hostLecture` method in the `ZipCodeWilmington` class by removing any intermediate _casting trick(s)_.
|
165
|
* Refactor the `hostLecture` method in the `ZipCodeWilmington` class by removing any intermediate _casting trick(s)_.
|
166
|
|
166
|
|
167
|
-# Part 9.0 - Test refactored classes.
|
|
|
|
|
167
|
+### Part 9.0 - Test refactored classes.
|
168
|
* Ensure that the `TestStudents`, `TestInstructors`, `TestPeople`, `TestZipCodeWilmington` classes were no affected by the refactor.
|
168
|
* Ensure that the `TestStudents`, `TestInstructors`, `TestPeople`, `TestZipCodeWilmington` classes were no affected by the refactor.
|
169
|
|
169
|
|
170
|
|
170
|
|
|
|
|
|
173
|
|
173
|
|
174
|
|
174
|
|
175
|
-
|
175
|
-
|
176
|
-### Notice the Design Flaw - Non-Intuitive Orientation
|
|
|
|
|
176
|
+# Notice the Design Flaw - Non-Intuitive Orientation
|
177
|
* You may have notice that `findById` makes it difficult to intuitively identify _which_ `Person` object is being returned.<br>
|
177
|
* You may have notice that `findById` makes it difficult to intuitively identify _which_ `Person` object is being returned.<br>
|
178
|
Additionally, it's challengaing to ensure **every** `Person` instance has a unique ID amongst its respective `People` subclass.<br>
|
178
|
Additionally, it's challengaing to ensure **every** `Person` instance has a unique ID amongst its respective `People` subclass.<br>
|
179
|
To remedy this issue, we redesign and refactor.
|
179
|
To remedy this issue, we redesign and refactor.
|