Portfolio

Blog

My articles

Interface Segregation Principle (ISP):

  • Description: Clients should not be forced to implement interfaces they do not use.
  • Before ISP:
interface Worker {
    void work();
    void eat();
}
  • After ISP:
interface Workable {
    void work();
}

interface Eatable {
    void eat();
}

class Worker implements Workable, Eatable {
    @Override
    public void work() {
        // Work logic
    }

    @Override
    public void eat() {
        // Eat logic
    }
}

Web Developer

© Michał Pieróg. All Rights Reserved.

Scroll to Top