Hexagonal Architecture Relevance Example

From BITPlan cr Wiki
Revision as of 13:18, 13 February 2026 by Wf (talk | contribs) (pushed from cpsa-f by wikipush)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Group


https://docs.google.com/spreadsheets/d/1zgT36ZAHIHace2nUwtbzDuLvC6-r0Qbxdh5_8WjDGXY/edit?usp=sharing

  1. Page4 Java Code
  2. Page9 Component with ports -> turned version of it
  3. Page18 Ownership of interface

3D Animations

Code

interface ForCalculatingTaxes {
    double taxOn(double amount);
}

interface ForGettingTaxRates {
    double taxRate(double amount);
}

class FixedTaxRateRepository implements ForGettingTaxRates {
    public double taxRate(double amount) {
        return 0.15;
    }
}

class TaxCalculator implements ForCalculatingTaxes {
    private ForGettingTaxRates taxRateRepository;
    
    public TaxCalculator(ForGettingTaxRates taxRateRepository) {
        this.taxRateRepository = taxRateRepository;
    }
    
    public double taxOn(double amount) {
        return amount * taxRateRepository.taxRate(amount);
    }
}

class Main {
    public static void main(String[] args) {
        ForGettingTaxRates taxRateRepository = new FixedTaxRateRepository();
        ForCalculatingTaxes myCalculator = new TaxCalculator(taxRateRepository);
        System.out.println(myCalculator.taxOn(100));
    }
}


Result

T2 Relevance.JPG

T1 exercise result RQ 02.JPG