것을 목표로 한다. 이 유닛은 나머지 시스템 없이도 존재할 수 있어야 한다. 하나의 유닛이 외
부 세계와 연계되는 방식은 두 가지 형태의 계약 조건으로 표현할 수 있다. 하나는 제공하는 인
터페이스이고 다른 하나는 제공받는 인터페이스이다. 유닛은 다른 것에 의존적이어서는 안 된
다. 특히 공유된 글로벌 상태나 싱글턴
Singleton
객체들은 의존적인 면이 강하다.
TIP
글로벌 변수나 싱글턴 객체는 신뢰할 만한 테스트에 대한 저주와 같다. 숨겨진 의존성이 있다면 하나의 유닛
을 쉽게 테스트할 수 없다.
하나의 코드 유닛이 제공하는 인터페이스는 단순히 어떤 메서드이거나 멤버 함수, 이벤트, 속
성일 수 있다. 또는 콜백 형태의 인터페이스일 수도 있다. 이러한 인터페이스는
API
를 통해 상
호 작동하는 객체들에 의해 결정된다. 공개(
public
) 메서드에 쓰이는 매개 변수의 자료형일
수도 있고, 구독하고 있는 메시지일 수도 있다. 예를 들어
Date
매개 변수를 요구하는
Invoice
클래스의 경우
Date
자료형의 인터페이스에 의존적이다.
하나의 클래스와 상호 작동하는 객체들은 생성자의 매개 변수로서 전달되어야 한
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.