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

← Go back
Day #5 TIL.
2년 전

TIL (Today I Learned)

// 2022.02.21

오늘 읽은 범위

// Chapter 3: Functions

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

  • The first rule of functions is that they should be small.

    The second rule of functions is that they should be smaller than that.

  • How do you write functions like this?

    Initial functions came out long and complicated, with lots of indenting and nested loops, long argument lists, names that are arbitrary and duplicated code.

    Massage and refine code

    Splitting out functions, changing names, eliminating duplication, shrinking the methods and reordering them while keeping the tests passing.
    I don't write them that way to start. I don't think anyone could

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

  • My code is my legacy. I always said that I need to think through before I write code, but in reality, I barely looked it back. Probably only when I need to check the way "my own" functions work. I learned so much from this chapter. Especially how I should name my functions to prevent confusion on how it works. Also, I understand more about the term "Functions should do one thing". I could not get the range of "one thing", and I ended up writing too many functions. Of course, I gave up after a few attempts, but now it is more clear in my head (unfortunately not perfect yet...).

  • I need a plan before I code, and I need to refactor it to make a better one.

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

  • Feel like I can only learn by practice