Hexagonal Architecture Relevance Example: Difference between revisions

From BITPlan cr Wiki
Jump to navigation Jump to search
No edit summary
m (Wf moved page RQ 2026-02-03/blue to Hexagonal Architecture Relevance Example without leaving a redirect)
 
(No difference)

Latest revision as of 13:22, 13 February 2026


  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));
    }
}


Relevance

TestSheet

Tax Test data


T2 Relevance.JPG

T1 exercise result RQ 02.JPG