[pukiwiki]
I am a huge fan of [[Diigo:http://www.diigo.com/user/ken_wakita%5D%5D!
– [[[JavaSpecialists 123] – Strategy Pattern with Generics:http://www.javaspecialists.co.za/archive/newsletter.do?issue=123%5D%5D –
昨日、スパークリングワインを飲みつつ Generics の使い方について悩んでいたのだけど、氷解したような気がする。getDetailedType を書くしかないので。Wadler のお墨付きがあるので安心できます。
Annotations:
<ul>
<li>
<div><div>Inside TaxPayer, we want to use the derived class P directly in the extortCash() method. However, the only way of getting an instance without compiler warnings is to pass it in from the subclass. We can solve this issue with a factory method called <code>getDetailedType()</code> that returns the subclass.</div></div>
</li>
<li>
<div><div>The beauty of using generics here is that EmployeeTaxStrategy does not need to downcast anymore.</div></div>
</li>
</ul>
Tags:
<a href="http://www.diigo.com/user/ken_wakita/java" rel="tag">java</a>
<a href="http://www.diigo.com/user/ken_wakita/tutorial" rel="tag">tutorial</a>
[/pukiwiki]