💡 인터페이스 분리 원칙

인터페이스 분리 원칙 이란

<aside> 💡 클라이언트가 자신이 이용하지 않는 메서드에 의존하지 않아야 한다는 원칙

</aside>

인터페이스 분리 원칙 위배 예시

interface Employee {
	fun calculatePay() // CFO만 사용 
	fun save() // CTO 만 사용 
	fun reportHours() // COO만 사용 
}

class CTO : Employee
class CFO : Employee
class COO : Employee

인터페이스 분리 원칙 지키기

interface CTOInterface {
	fun save()
}

interface CFOInterface {
	fun calculatePay()
}

interface COOInterface {
	fun reportHours()
}

interface Employee : CTOInterface, CFOInterface, COOInterface

class CTO : CTOInterface
class CFO : CFOInterface
class COO : COOInterface