@@ -1321,14 +1321,12 @@ def view(request):
13211321
13221322```
13231323
1324- ### ** Dependency Inversion Principle (DIP)**
1324+ ### ** 의존성 역전 원칙( Dependency Inversion Principle (DIP) )**
13251325
1326- > “Depend upon abstractions, not concrete details ”,
1326+ > “구체적인 세부사항이 아니라, 추상화에 의존하세요 ”,
13271327> Uncle Bob.
13281328
1329- Imagine we wanted to write a web view that returns an HTTP response that
1330- streams rows of a CSV file we create on the fly. We want to use the CSV writer
1331- that is provided by the standard library.
1329+ 우리가 즉석에서 만든 CSV의 행(row) 파일을 스트리밍하는 HTTP response를 출력하는 웹 뷰를 만들고 싶었다고 상상해봅시다.
13321330
13331331** Bad**
13341332
@@ -1369,16 +1367,15 @@ def some_view(request):
13691367
13701368```
13711369
1372- Our first implementation works around the CSV's writer interface by
1373- manipulating a ` StringIO ` object (which is file-like) and performing several
1374- low level operations in order to farm out the rows from the writer. It's a lot
1375- of work and not very elegant .
1370+ 우리의 첫 번째 구현은 ` StringIO ` 객체(file-like와 유사함)를 조작하고
1371+ writer로 부터 행을 파밍하기 위해 낮은 레벨의 작업을 수행함으로써
1372+ CSV writer의 인터페이스를 중심으로 작동합니다.
1373+ 이는 많은 작업을 요구하고 세련된 방법이 아닙니다 .
13761374
1377- A better way is to leverage the fact that the writer just needs an object with
1378- a ` .write() ` method to do our bidding. Why not pass it a dummy object that
1379- immediately returns the newly assembled row, so that
1380- the ` StreamingHttpResponse `
1381- class can immediate stream it back to the client?
1375+ 더 나은 방법은 writer가 우리의 명령을 수행하기 위해
1376+ ` .write() ` 메서드가 있는 객체가 필요하다는 사실을 활용하는 것입니다.
1377+ StreamingHttpResponse 클래스가 즉시 클라이언트로 다시 스트리밍할 수 있도록
1378+ 새로 조립된 행을 즉시 반환하는 더미 객체를 전달하는 것은 어떨까요?
13821379
13831380** Good**
13841381
@@ -1412,15 +1409,12 @@ def some_streaming_csv_view(request):
14121409
14131410```
14141411
1415- Much better, and it works like a charm! The reason it's superior to the
1416- previous implementation should be obvious: less code (and more performant) to
1417- achieve the same result. We decided to leverage the fact that the writer class
1418- depends on the ` .write() ` abstraction of the object it receives, without caring
1419- about the low level, concrete details of what the method actually does.
1412+ 훨씬 낫고, 그것은 매력적으로 작동합니다!
1413+ 이전 구현보다 우수한 이유는 분명합니다: 동일한 결과를 얻기 위해 코드를 적게 사용(그리고 성능을 더 높임)
1414+ 우리는 메서드가 실제로 무엇을 하는지에 대한 낮은 수준의 구체적인 세부 사항에 신경 쓰지 않고,
1415+ writer 클래스가 echo 객체의 .write() 추상화에 의존한다는 사실을 활용하기로 결정했습니다.
14201416
1421- This example was taken from
1422- [ a submission made to the Django documentation] ( https://code.djangoproject.com/ticket/21179 )
1423- by this author.
1417+ 이 예는 이 저자가 [ Django 다큐먼트에 제출한 문서] ( https://code.djangoproject.com/ticket/21179 ) 에서 가져온 것입니다.
14241418
14251419** [ ⬆ back to top] ( #table-of-contents ) **
14261420
0 commit comments