@@ -754,19 +754,17 @@ print(person.name_as_first_and_last) # => ["Ryan", "McDermott"]
754754
755755## ** Classes**
756756
757- ### ** Single Responsibility Principle (SRP)**
757+ ### ** 단일 책임 원칙( Single Responsibility Principle (SRP) )**
758758
759- Robert C. Martin writes:
759+ Robert C. Martin 는 다음과 같이 저술한 적이 있습니다.
760760
761- > A class should have only one reason to change .
761+ > 클래스를 변경하는 이유는 오직 하나여야 합니다 .
762762
763- "Reasons to change" are, in essence, the responsibilities managed by a class or
764- function.
763+ '변경하는 이유' 란, 본질적으로 클래스나 함수에 의해 관리되는 책임을 말합니다.
765764
766- In the following example, we create an HTML element that represents a comment
767- with the version of the document:
765+ 다음의 예시는 문서의 버전을 포함하여 HTML 주석을 나타내는 요소를 만듭니다.
768766
769- ** Bad **
767+ ** 나쁜 예 **
770768
771769``` python
772770from importlib import metadata
@@ -787,16 +785,16 @@ class VersionCommentElement:
787785VersionCommentElement().render()
788786```
789787
790- This class has two responsibilities:
788+ 이 클래스는 두 가지 책임을 가집니다.
791789
792- - Retrieve the version number of the Python package
793- - Render itself as an HTML element
790+ - 파이썬 패키지의 버전 번호를 검색
791+ - 그 자체를 HTML 요소로써 렌더링
794792
795- Any change to one or the other carries the risk of impacting the other .
793+ 둘 중 어느 하나를 변경하게 되면 다른 하나에 영향을 미칠 위험성이 있습니다 .
796794
797- We can rewrite the class and decouple these responsibilities:
795+ 다음과 같이 클래스를 다시 작성하여 위의 책임들을 분리할 수 있습니다.
798796
799- ** Good **
797+ ** 좋은 예 **
800798
801799``` python
802800from importlib import metadata
@@ -821,6 +819,7 @@ class VersionCommentElement:
821819VersionCommentElement(get_version(" pip" )).render()
822820```
823821
822+ 결과적으로 클래스는 그 자체를 렌더링 하는 것에만 신경쓰면 됩니다. 클래스는 인스턴트화 중에 버전 텍스트를 받고 이 텍스트는 ` get_version() ` 라는 분리된 함수에 의해 생성됩니다. 클래스를 변경하는 것이
824823The result is that the class only needs to take care of rendering itself. It
825824receives the version text during instantiation and this text is generated by
826825calling a separate function, ` get_version() ` . Changing the class has no impact
0 commit comments