Java Interfaces in CS 1 Textbooks |
Java Interfaces in CS 1 TextbooksJava's interface construct allows for a clear distinction between subtype polymorphism based on a shared interface and code reuse based on class extension or inheritance. Design Patterns argues that in an object-oriented setting, programming should be done to an interface, not to an implementation, that class inheritance is a mechanism for code reuse rather than for subtyping and polymorphism, and that even composition should be favored over class inheritance. We conclude from this that interfaces should be introduced prior to and given more focus than abstract classes and class inheritance. We survey 27 textbooks from major publishers to show that very few available texts teach Java this way. We propose an alternative ordering of material that will promote the principles mentioned above. Thomas VanDrunen, Wheaton College
|