Community

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

← Go back
Clean code #6 객체와 자료 구조
#clean_code
2년 전
633

오늘 읽은 범위

6 객체와 자료구조

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

  • 분별 있는 프로그래머는 모든 것이 객체라는 생각이 미신임을 잔 안다. 때로는 단순한 자료 구조와
    절차적인 코드가 가장 적합한 상황도 있다.


    (Mature programmers know that the idea that everything is an object is a myth. Sometimes you really do want simple data structures with procedures operating on them)

  • 우수한 소프트웨어 개발자는 편견 없이 이 사실을 이해해 직면한 문제에 최적인 해결책을 선택한다
    (Good software developers understand these issues without prejudice and choose the approach that is best for the job at hand)

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

무언가 한방 먹은 듯한 느낌이다.

나는 그동안 자연스럽게 최신의 코딩 스타일이나 내가 좀 더 나중에 접한 스타일이라면 더 뛰어난 것처럼 생각하곤 했다

예를 들어 C는 객체나 클래스의 개념이 없기 때문에 예전 스타일이고 과거의 유물같이 여겼던것 같다

또는 최근의 'Go lang, 'Swift'등이 더욱 진보한 언어라고 생각했었는지도 모른다

그래서인지 나는 struct를 만든 뒤 함수를 추가하고, enum을 만든 뒤에도 아무 생각없이 함수를 추가하곤 했다.

사실은 어떤 구현 방식이 좋은지 객체로서 내부를 숨기며 구현할 것인지 단순한 데이터로서 모든 것을 공개하고 다른 객체에게 처리를 넘길 것인지 생각하지 않았고

그저 손이 가는대로 결국 그저 작동하는 코드 밖에는 쓰지 못했었다

I got clobbered by this chapter

I just consider newest coding style as the best, anything I learned recently as better solution

For instance I thought 'C' as ancient language cause even it doesn't support class or object orient style

And some newest languages like 'Go lang', 'Swift' are better

Maybe that's why I make function in struct even if in enum all the time without any consideration

Actually I didn't think what is the best or better decision between creating object which hide internal structure and provide useful methods or creating data structure which just open internal data and delegate actual action to another object using it

I just write some piece of codes which only run along anything comes in my head

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

  • 디미터 법칙 (The Law of Demeter)



    이 규칙이 왜 생겨났는지 이것을 고려하면 어떤 이득이 있는지는 알것 같다
    하지만 실제 코드에 자연스럽게 녹아들게 하는것이 어렵다

    I got some idea why this rule is appear and what's the benefit according to follow it
    but when writing some code naturally in this rule is quite difficult