SOLID

Interface segregation principle

A client should never be forced to implement an interface that it doesn’t use.

Clients shouldn’t be forced to depend on methods they do not use.

Many client specific interfaces are better than one general purpose interface.

Many client specific classes are better than one general purpose class.

interface ShapeInterface {
    public function area();
    public function volume();
}
interface ShapeInterface {
    public function area();
}

interface SolidShapeInterface {
    public function volume();
}

class Cuboid implements ShapeInterface, SolidShapeInterface {
    public function area() {
        // calculate the surface area of the cuboid
    }

    public function volume() {
        // calculate the volume of the cuboid
    }
}

Dziękuję za uwagę :)

ISP

By Tomasz Warkocki

ISP

SOLID - ISP

  • 1,991