←Older revision | Revision as of 08:49, 23 March 2009 | ||
Line 20: | Line 20: | ||
[[Category:APIDesignPatterns:Clarity]] | [[Category:APIDesignPatterns:Clarity]] | ||
+ | [[Category:APIDesignPatterns]] |
←Older revision | Revision as of 08:49, 23 March 2009 | ||
Line 20: | Line 20: | ||
[[Category:APIDesignPatterns:Clarity]] | [[Category:APIDesignPatterns:Clarity]] | ||
+ | [[Category:APIDesignPatterns]] |
←Older revision | Revision as of 20:30, 27 December 2008 | ||
Line 19: | Line 19: | ||
On the other hand, as [[Singletonizer]] pattern shows, using this style in [[ProviderAPI]], where the ''open'' is done once by the [[API]] infrastructure is quite OK. | On the other hand, as [[Singletonizer]] pattern shows, using this style in [[ProviderAPI]], where the ''open'' is done once by the [[API]] infrastructure is quite OK. | ||
- | [[Category:APIDesignPatterns: | + | [[Category:APIDesignPatterns:Clarity]] |
←Older revision | Revision as of 14:29, 26 December 2008 | ||
Line 7: | Line 7: | ||
<source lang="java" snippet="misuse.prjconfig.correct.trivial.access"/> | <source lang="java" snippet="misuse.prjconfig.correct.trivial.access"/> | ||
- | no longer compiles. | + | no longer compiles. The problem is that '''provider''' is of unknown bound '''<?>'''. Whenever it is used, the compiler uses new ''unknown bound'', as such the call to getter returns one unknown type and the setter needs another unknown type. They are not the same. To work around that, one needs to create new [[OpenMethod]]: |
<source lang="java" snippet="misuse.prjconfig.correct.openmethod"/> | <source lang="java" snippet="misuse.prjconfig.correct.openmethod"/> | ||
- | or [[OpenClass]]: | + | which ''opens'' the provider parameter and binds it to '''<C>''' bound. All references to that variable then represent the same type during the method execution or during existence of [[OpenClass]] instance: |
<source lang="java" snippet="misuse.prjconfig.correct.openclass"/> | <source lang="java" snippet="misuse.prjconfig.correct.openclass"/> |
←Older revision | Revision as of 14:23, 26 December 2008 | ||
Line 5: | Line 5: | ||
The '''getActive''' and ''setActive''' methods could take '''ProjectConfiguration''' class as parameter, but that would not be correct - it would allow a user of the [[API]] to take configuration from one project and try to activate it on different one. By use of ''<Configuration extends ProjectConfiguration>'' bound, this is prevented. Yet, this very complicates life of clients of this API, as following code: | The '''getActive''' and ''setActive''' methods could take '''ProjectConfiguration''' class as parameter, but that would not be correct - it would allow a user of the [[API]] to take configuration from one project and try to activate it on different one. By use of ''<Configuration extends ProjectConfiguration>'' bound, this is prevented. Yet, this very complicates life of clients of this API, as following code: | ||
- | <source lang="java" snippet="misuse.prjconfig. | + | <source lang="java" snippet="misuse.prjconfig.correct.trivial.access"/> |
no longer compiles. Instead of it one needs to either use the [[OpenMethod]]: | no longer compiles. Instead of it one needs to either use the [[OpenMethod]]: |
New page: When dealing with objects that produce and consume generic type of unknown bounds, it is necessary to ''open'' the type before its use. One can either use an OpenMethod or...
New page