Community

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

← Go back
Clean code #9, #10
#clean_code
2년 전
751

오늘 TIL 3줄 요약

  • 깔끔하지 않은 테스트 코드는 테스트 코드가 없는 것보다 나쁘다
    Non-testing is better than messy test code

  • 깨끗한 코드는 주의 깊게 작성한 코드다

  • 독자를 생각하며 코드를 쓰자

오늘 읽은 범위

9장 단위 테스트, 10장 클래스

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

  • 문제는 실제코드가 진화하면 테스트 코드도 변해야 한다는 데 있다.
    그런데 테스트 코드가 지저분할수록 변경하기 어려워진다
    ( The problem is that tests must change as the production code evolves. The dirtier the tests, the harder they are to change. )

  • 클래스는 작아야 한다, 클래스가 응집력을 잃는다면 쪼개라


    (Class should be small, When classes lose cohesion, split them)

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

지금까지 테스트 코드를 작성하고 사용해 본적이 없어서 내용을 이해하기는 어려웠다

하지만 깨끗한 테스트 코드의 필요성을 이번 챕터로 알 수 있었는데

그것은 우리가 코드를 깨끗하게 작성해야 하는 이유와 같았다

깨끗하지 않은 코드는 가독성이 좋지 않고 수정하기 어려워진다

코드가 수정되면 그에 따라 테스트 코드도 수정해야하지만 테스트 코드가 나쁠수록 수정은 쉽지 않을것이다

내가 작성한 클래스가 응집력이 떨어진다는 느낌을 받은 적이있다

시간이 지날수록 새로운 변수, 함수 등을 추가하는데 처음 생각했던 역할과는 점점 멀어지게 된다

바로 그럴 때 클래스를 쪼개서 클래스를 더욱 단단하게 만들어야 한다는것을 알게 되었다

I've never written test code, used it so It's hard to understand this chapter

But one thing I can only acquire from this chapter is that I must write clean test code

Writing messy test-code has same effect with writing messy code

It's so had to modify as It's has poor readability

When code is changed test-code must be changed also

If test-code is messy It'll be very hard to change

I felt that the class I make is lose cohesion

I add more and more functions and variables in class as I write more code

It seems drift apart from the concept I thought at first

That's the moment I have to split the class so I can maintain code banded well togehter

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

  • F.I.R.S.T

  • S.R.P

오늘 읽은 다른사람의 TIL