APIFest08:Report
From APIDesign
Line 10: | Line 10: | ||
Both guys managed to find a problem in solution 04. There were multiple problems as demonstrated by [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/psmid/against-solution04/test/apifest/CurrencyTest.java Petr], however the most obvious one was source incompatibility caused by the addition of new method into a subclassable interface as shown by [http://source.apidesign.org/hg/apifest08/file/621462e58e22/taskx/ked/against-solution04/test/apifest/CurrencyTest.java Jan] and [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/jtulach/against-solution04/test/apifest/CurrencyTest.java me]. The lesson to take is that if one is seeking for 100% [[BackwardCompatibility]] one needs to prevent modifications to classes that can be subclassed. | Both guys managed to find a problem in solution 04. There were multiple problems as demonstrated by [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/psmid/against-solution04/test/apifest/CurrencyTest.java Petr], however the most obvious one was source incompatibility caused by the addition of new method into a subclassable interface as shown by [http://source.apidesign.org/hg/apifest08/file/621462e58e22/taskx/ked/against-solution04/test/apifest/CurrencyTest.java Jan] and [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/jtulach/against-solution04/test/apifest/CurrencyTest.java me]. The lesson to take is that if one is seeking for 100% [[BackwardCompatibility]] one needs to prevent modifications to classes that can be subclassed. | ||
+ | |||
+ | === Problems in Solution 06 === | ||
+ | |||
+ | The author of solution six did few compatibility mistakes. First of all, as [http://source.apidesign.org/hg/apifest08/file/621462e58e22/taskx/ked/against-solution06/test/apifest/CurrencyTest.java Jan demonstrates], the once '''public''' field ''Convertor.one'' disappeared in subsequent revision, which is clearly incompatible for clients using it. | ||
+ | |||
+ | I found an [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/jtulach/against-solution06/test/apifest/CurrencyTest.java interesting source incompatibility] caused by adding overloaded version of constructor. If there are two methods with the same name and number of parameters, but different types, one can try to call them with '''null''' and the compiler will refuse the compilation: | ||
+ | {{{ | ||
+ | against-solution06/test/apifest/CurrencyTest.java:18: reference to Convertor is ambiguous, both method Convertor(java.math.BigDecimal,java.util.Currency,java.util.Currency) in org.apidesign.apifest08.currency.Convertor and method Convertor(org.apidesign.apifest08.currency.Convertor.RateProvider,java.util.Currency,java.util.Currency) in org.apidesign.apifest08.currency.Convertor match | ||
+ | Convertor c = new Convertor(null, cur1, cur2); | ||
+ | }}} | ||
+ | Obviously the code compiled before the second method was introduced, but than it failed. This is not that big incompatibility in practise, but it is enough to loose in [[APIFest08]]. | ||
+ | |||
+ | Petr [http://source.apidesign.org/hg/apifest08/file/2ae6e4aa7aef/taskx/psmid/against-solution06/test/apifest/CurrencyTest.java exploited another functional incompatibility]. The text of a thrown exception changed between two releases. As such it is enough to generate the exception and compare the text. A thing to remember? There are different [[APITypes|kinds of APIs]], text messages being one of them. For purpose of [[APIFest08]] all of them are equal. | ||
+ | |||
+ | === Problems in Solution 07 === | ||
+ | |||
+ | === Problems in Solution 11 === | ||
+ | |||
+ | === Problems in Solution 13 === | ||
+ | |||
+ | === Problems in Solution 14 === |
Revision as of 07:38, 26 October 2008
The celebration of 10 years of NetBeans releases is in progress and that is why it is also time to celebrate all those who contributed to the NetBeans architecture, and design practices which makes NetBeans platform the most stable Java rich client application framework.
The best way to have fun is to play games. The best way to learn is to play as well. The best way to teach is to organize such game. When me and CZJUG lead Jakub Podlešák realized that, we decided to organize similar game as described in Chapter 17 of TheAPIBook. It is a game to teach, learn and have fun while designing architecture and APIs and practising backward compatibility principles in software interfaces.
There were four base rounds ([[APIFest08:Task1.5|1], 2, 3, 4) in the APIFest08. We started with fourteen participants. However as the competition advanced further and further, only those who really eager to win managed to finish all four design tasks. Still, six solutions advanced to the final judgment day/week.
The judgment round is in fact the start of the real competition. However it is also much more difficult than the first four rounds. Instead of looking into own solution, one needs to dig into solutions provided by others and seek for left compatibility problems which is different and time consuming. Still I am glad that two participants, Petr Šmíd and Jan Žák did not give up and sent me their hacks showing BackwardCompatibility evolution problems in many solutions.
Contents |
Problems in Solution 04
Both guys managed to find a problem in solution 04. There were multiple problems as demonstrated by Petr, however the most obvious one was source incompatibility caused by the addition of new method into a subclassable interface as shown by Jan and me. The lesson to take is that if one is seeking for 100% BackwardCompatibility one needs to prevent modifications to classes that can be subclassed.
Problems in Solution 06
The author of solution six did few compatibility mistakes. First of all, as Jan demonstrates, the once public field Convertor.one disappeared in subsequent revision, which is clearly incompatible for clients using it.
I found an interesting source incompatibility caused by adding overloaded version of constructor. If there are two methods with the same name and number of parameters, but different types, one can try to call them with null and the compiler will refuse the compilation: {{{ against-solution06/test/apifest/CurrencyTest.java:18: reference to Convertor is ambiguous, both method Convertor(java.math.BigDecimal,java.util.Currency,java.util.Currency) in org.apidesign.apifest08.currency.Convertor and method Convertor(org.apidesign.apifest08.currency.Convertor.RateProvider,java.util.Currency,java.util.Currency) in org.apidesign.apifest08.currency.Convertor match
Convertor c = new Convertor(null, cur1, cur2);
}}} Obviously the code compiled before the second method was introduced, but than it failed. This is not that big incompatibility in practise, but it is enough to loose in APIFest08.
Petr exploited another functional incompatibility. The text of a thrown exception changed between two releases. As such it is enough to generate the exception and compare the text. A thing to remember? There are different kinds of APIs, text messages being one of them. For purpose of APIFest08 all of them are equal.