Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can, if you wish, incorporate the Abstract Factory pattern to deal with the creation of TaxPolicy objects.</p> <p>In your case that would involve:</p> <p><code>AbstractTaxPolicyFactory</code> – an interface with abstract methods <code>createItemCategoryTaxPolicy()</code> and <code>createImportDutyTaxPolicy()</code>, that would create abstract tax policies <code>ItemCategoryTaxPolicy</code> and <code>ImportDutyTaxPolicy</code> (these would be your "families of related products")</p> <p><code>USTaxPolicyFactory</code> and <code>ChinaTaxPolicyFactory</code> – two concrete factories, each implementing those two methods to create concrete tax policies like <code>ChinaImportDutyTaxPolicy</code>, etc.</p> <p><code>ItemCategoryTaxPolicy</code> and <code>ImportDutyTaxPolicy</code> – interfaces for the respective concrete tax policies</p> <p><code>USItemCategoryTaxPolicy</code>, <code>USImportDutyTaxPolicy</code>, <code>ChinaItemCategoryTaxPolicy</code>, and <code>ChinaImportDutyTaxPolicy</code> – the four concrete tax policies. For instance, at runtime the <code>USImportDutyTaxPolicy</code> would be created by the <code>USTaxPolicyFactory</code>, and would be of <code>ImportDutyTaxPolicy</code> type. </p> <p><code>SalesPolicy</code> would be your client that would use the abstract factory and abstract tax policies interfaces, e.g.:</p> <pre><code>AbstractTaxPolicyFactory absFactory = new ChinaTaxPolicyFactory(); // or use a static factory method: // TaxPolicyFactoryCreator.createNewFactory(Country.CHINA); ItemCategoryTaxPolicy itemCatTaxPolicy = absFactory.createItemCategoryTaxPolicy(); addTaxPolicy(itemCatTaxPolicy); ImportDutyTaxPolicy importDutyTaxPolicy = absFactory.createImportDutyTaxPolicy(); addTaxPolicy(importDutyTaxPolicy); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload