KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
"API design is like sex: make one mistake and support it for the rest of your life" ( Josh Bloch on twitter ) There are many design mistakes in the Java library. Stack extends Vector ( discussion ), and we can't fix that without causing breakage. We can try to deprecate Integer.getInteger ( discussion ), but it's probably going to stay around forever. Nonetheless, certain kinds of retrofitting can be done without causing breakage. Effective Java 2nd Edition, Item 18: Prefer interfaces to abstract classes : Existing classes can be easily retrofitted to implement a new interface". Examples: String implements CharSequence , Vector implements List , etc. Effective Java 2nd Edition, Item 42: Use varargs judiciously : You can retrofit an existing method that takes an array as its final parameter to take varags instead with no effect on existing clients. An (in)famous example is Arrays.asList , which caused confusions ( discussion ), but not breakage. This question is about a different kind of retrofitting: Can you retrofit a void method to return something without breaking existing code? My initial hunch points to yes, because: Return type doesn't affect which method is chosen at compile time See: <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.2.11"
Tags (comma-separated)
Save Edits
Cancel