Community

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

← Go back
Clean code #7
#clean_code
2년 전
791
1

오늘 읽은 범위

7장 오류처리

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

  • 강제로 예외를 일으키는 테스트 케이스를 작성한 후 테스트를 통과하게 코드를 작성하는 방법을 권장한다. 그러면 자연스럽게 try 블록의 트랜잭션 범위부터 구현하게 되므로 범위 내에서 트랜잭션 본질을 유지하기 쉬워진다
    ( Try to write tests that force exceptions, and then add behavior to your handler to sat- isfy your tests. This will cause you to build the transaction scope of the try block first and will help you maintain the transaction nature of that scope. )

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

지금까지 오류 처리에 대해 깊게 생각한적이 없었다.

오류 처리는 귀찮은 일이었고 코드가 컴파일이 되고 실행이 되면 그 이상 생각하고 싶지 않았다

나는 테스트 케이스를 작성한 적도, 오류 코드를 테스트한 적도 없을 뿐더러 트랜잭션이라는 개념도 이해가 가지 않는다

저자는 오류처리를 빠뜨리지 않으면서도 기존 흐름과 분리해 깔끔히 처리할 것을 권한다

특히 불확실한 null 값을 넘기지 말고 그 자리에서 최대한 처리할 것을 권한다

단순한 로그 보다는 확실한 예외를 발생시키는 것을 선호하고 있다

깨끗하면서도 안전한 코드 두 가지 모두 신경쓰라고 이야기한다

I didn't take care about handling error

It was hassle to me so when code is compiled and running well I stopped thinking about it

I've never written test case and I can't get the concept about transaction

But this chapter says "Handle error neatly, and separate it from other logic"

especially emphasize that " Handle issue in-place rather than passing the wrong and uncertain null value, throw certain exception rather than just logging error "
Write clean and safe code!

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

  • 트랜잭션 컨셉 (Transaction concept )

1 comment