Community

개발자 99% 커뮤니티에서 수다 떨어요!

← Go back
Clean code #8
#clean_code
2년 전
1,053
1

오늘 TIL 3줄 요약

  • 외부 코드를 가져다 쓰는 것은 생산성에 도움이 된다
    (Importing external library is helpful for productivity)

  • 하지만 생산성을 제외한 모든 부분에는 도움이 되지 않는다


    (But it's not helpful for everything except productivity)

  • 외부 코드에 의존하지 코드가 아닌 외부 코드를 컨트롤하는 코드를 만들자
    ( Write code that control external code rather than depending on it)

오늘 읽은 범위

8장 경계

책에서 기억하고 싶은 내용을 써보세요.

  • 통제가 불가능한 외부 패키지에 의존하는 대신 통제가 가능한 우리 코드에 의존하는 편이 훨씬 좋다. (It’s better to depend on something you control than on something you don’t control, lest it end up controlling you.)

  • 외부 패키지 테스트가 우리 책임은 아니다. 하지만 우리 자신을 위해 우리가 사용할 코드를 테스트하는 편이 바람직하다
    (It’s not our job to test the third-party code, but it may be in our best interest to write tests for the third-party code we use.)

오늘 읽은 소감은? 떠오르는 생각을 가볍게 적어보세요

그동안은 그저 외부 라이브러리가 괜찮아 보이면 믿고 사용하고는 했다

필자는 내가 사용할 코드를 테스트 하는것이 당연하다고 말한다

아마 내가 테스트 하지 않고 사용한 라이브러리가 오류를 일으키거나 버전이 변경되거나 (요즘은 자동으로 변경된 버전을 에디터가 적용시키곤 한다) 등의 이유로 무언가 제대로 돌아가지 않으면

그것을 디버깅하는 것에 엄청나게 고생할것이 틀림없다

왜냐하면 내가 만든 코드가 아니기 때문에 어디서 오류가 발생했는지 찾기 쉽지않고,

내가 외부 코드를 분리하지 않았기 때문에 외부 코드에서 오류가 발생했는지 조차 알기 어렵기 때문이다

When I found some library which is looks good I just used it until now

This chapter says "It's stand for reason that I have to test code which I'm going to use"

If some code I just copy and paste from extern source or library I just import from some github have some trouble, or even though version of library is changed and my code automatically update it (many editors may do it these-day)

It will be huge trouble for me I'll not be able to figure out which part cause error because I don't know the internal implementation of the library
And maybe I can't catch the library cause error because I didn't write test-code for it

궁금한 내용이 있거나, 잘 이해되지 않는 내용이 있다면 적어보세요.

  • Adaptor pattern


    외부 라이브러리나 API를 사용할때는 항상 적용해야 할까?
    기존 코드의 중요한 부분과 연관이 있다고 생각될때만 적용해야 할까?

    What's the best use-case?
    Do I have to make adaptor every time when using external library or calling API?


    Or only when something is considered crucial to other codes?

1 comment