[객체지향] SOLID란?

SOLID

Robert Cecil Martin, called Uncle bob

SRP(Single Responsibility Principle), 단일 책임 원칙, 솔로 플레이

OCP(Open Close Principle), 개방 폐쇄 원칙, 마술과 같은 원칙

Repository repository = new MemoryRepository(); // 기존의 기능
Repository repository = new JPARepository(); // 변경한 기능

LSP(Liskov Substitution Principle), 리스코프 치환 원칙

Barbara Liskov

ISP(Interface Segregation Principle), 인터페이스 분리 원칙

DIP(Dependency Inversion Principle), 의존 역전 원칙

// Repository repository = new MemoryRepository(); 
Repository repository = new JPARepository();
# Servicepublic class Service {
private final MemberRepository repo;

public Service(MemberRepository repo) {
this.repo = repo;
}
}
# Controllervar repository = new MemoryRepository();
Service service = new Service(repository);

--

--

--

Blog https://chrisjune.dev Work for www.29cm.co.kr

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
chrisjune

chrisjune

Blog https://chrisjune.dev Work for www.29cm.co.kr

More from Medium

Names in code. The basic guidelines.

How to discard an unstaged change with hunk edit mode

Getting list of Git files owned by a specific owner based on the CODEOWNERS file