Info |
---|
In this section we upgrade the code to use generics Why? The original code doesn’t deal with using other collection types very well, basically you would have to copy the code and change it. The tests are written, so we now move into a TDD way coding, don’t break the existing tests |
...
I’ve circled in red all the areas I want to address.
Line No | Issue | Proposed Solution |
---|---|---|
20 | TextFileSource - needs the declared as a generic | TextFileSource<T> |
20 | IDataSource - needs to be a generic | IDataSource<T> |
22 | Returning a, Iterable<String> is constraining. There are other collection types in the JDK that do not decend from Collection and do not implement the Iterable interface | Return the datatype that actually holds the data |
24 | The solution is too restrictive, binding the functor to an ArrayList<String> | I would like to tie the ICollectionLoader to the generic parameter type that will be passed into TextFileSouce |
32 | Same as line 22 | Return the datatype that actually holds the data |
32 | ICollectionLoader should be bound to the generic type passed into TextFileSource | ICollectionLoader<T> |
34 | This is crazy, it’s such tightly coupled code to ArrayList<String> | The object should be passed in, so the method signature should look like this
The idea being that |