2009년 1월 4일 일요일

MVC 예찬론

Model-View-Controller Song
Lyrics by James Dempsey

Model View, Model View, Model View ControllerMVC’s the paradigm for factoring your code,into functional segments so your brain does not explode.To achieve reusability you gotta keep those boundaries clean, Model on the one side, View on the other, the Controller’s in between.


MVC 는 코드를 기능에 따라 나눠주는 패러다임이지
우리의 머리가 쉴 수 있게 해주지
재사용을 위해서는 깔끔하게 나눠줘야 한다네
한쪽에는 모델이, 다른 편에는 뷰가 , 그 사이에는 컨트롤러가 있다네

Model View - It’s got three layers like Oreos do.Model View creamy Controller

모델 뷰, 크림 샌드 쿠키처럼 삼층으로 되어 있지
모델 뷰 컨트롤러
모델 뷰, 모텔 뷰, 모델 뷰 컨트롤러
Model objects represent your applications raison d’tre.Custom classes that contain data logic and et cetra.You create custom classes in your app’s problem domain,then you can choose to reuse them with all the views,but the model objects stay the same.

모델 객체는 애플리케이션의 존재의 의미지
데이터, 논리 같은 게 전부 들어있는 객체지
그 클래스는 애플리케이션이 문제 해결을 위한
클래스지
어떤 뷰에 대해서도 재사용할 수 있지
뷰가 바뀌어도 모델 객체는 그대로 남지
You can model a throttle in a manifold,Model level two year old.Model a bottle of fine Chardonnay.Model all the twaddle stuff people say.Model the coddle in a boiling eggs.Model the waddle in Hexley’s legs.

자동차의 움직임도 모델로 만들 수 있고
아이의 뒤뚱거림도 모델로 만들 수 있어
근사한 와인도 모델로 만들 수 있고
사람들 말하는
것도 모델로 만들 수 있어
물 속에서 팔팔 끓는 달걀까지도
바닷물의 출렁임도 모델로 만들 수 있어
One, two, three, four.Model View - You can model all the models that pose for GQ.Model View Controller

모델 뷰, GQ 모델의 포즈도 모델로 만들 수 있네
모델 뷰 컨트롤러
View objects tend to be controls that view and edit,Cocoa’s got a lot of those, well written to its credit.Take an NSTextView, hand it any old Unicode string,the user interacts with it, it can hold most anything.But the view don’t knows about the Model:That string could be a phone number or the words of Aristotle.Keep the coupling loose and so achieve a massive level of reuse.

뷰 객체는 표시하고 편집하기 위한 컨트롤
코코아에는 훌륭한 컨트롤이 가득하네
NSTextView 하나만 집어서, 아무 유니코드
문자열이나 건네줘 보세
사용자가 조작할 수도 있고, 거의 무엇이든 담을 수 있네
하지만 뷰는 모델의 대해 모른다네
그 문자열을
전화번호일 수도 있고, 아리스토텔레스의 작품일 수도 있네
연결을 느슨하게
재사용용을 최고로 끌어 올리세
Model View - All rendered very nicely in Aqua blueModel View Controller

모델 뷰, 아쿠아 블루로 멋지게 표시되네
모델 뷰 컨트롤러
You’re probably wondering now.You’re probably wondering how,the data flows between Model and View.The Controller has to mediate,between each layer’s changing state,to synchronize the data of the two.It pulls and pushes every changed value.Yeah.

궁금하겠지
궁금할거야
데이터는 모델과 뷰 사이에서 움직이지
컨트롤러는 둘 사이의 중계자
각 계층의 상태가 바뀔때면

둘의 데이터를 동기화 시켜주지
바뀐 값들을 부지런히 날라주지
Model View - mad props to the smalltalk crew!for Model View Controller

모델 뷰, 스몰토를 만든 이들에게 영광 있으리
모델 뷰 컨트롤러

Model View - it’s pronouced Oh Oh not Uh UhModel View Controller

모델 뷰, 어어가 아니라 오오라네
모델 뷰 컨트롤러

There’s a bit more on this story, a few more miles upon this road,well nobody seems to get much glory writing controller code.Well the model is mission critical and gorgeous is the view,But I’m not being lazy, but sometimes it’s just crazy how much code i write is just glue.And it wouldn’t be so tragic,but the code ain’t doing magic:it’s just moving values through.And I wish I had a dimefor every single time I set a TextField’s stringValue.

이 얘기도 거의 끝나가네
조금만 더 가면 된다네
컨트롤러 코드를 만드는 사람들은
그리 빛을 발하지 못하네
모델은 중요한
임무를 맡지
뷰는 예쁘게 치장하고 사람들 앞에 나타나지
나는 게이름뱅이. 하지만 때론 미쳐 돌아가지
아무리 많은 코드를 작성해도
연결 고리만 될 뿐이지
그리 비참한 것은 아니라네
별 볼일 없는 코드긴 하지만 말이지
열심히 값을 떠 날라
주지
텍스트필드에 문자열을 보낼때마다
100원씩만 받아도 좋겠어
Model View - how we’re gonna deep-six all that glueModel View Controller

모델 뷰
어떻게 하면 지루한 일을 집어치울까
모델 뷰 컨트롤러
Controller’s know the Model and View veryuahh - intimately They often are hardcoding which is very verboten for reusability.But now you can connect any value you selectto any view property.And I think you’ll start binding,then you’ll be finding less code in your source tree.Yeah I know I was astounded,that’s not even a rhyme.

컨트롤러는 모델과 뷰 모두하고 친하네
재사용의 가장큰적, 하드코딩도 종종 쓴다네
하지만 모델키를 어떤 뷰 속성에도 마음대로 연결할
수 있다네
일단 연결을 하다보면
소스 트리에 들어가는 코드는 그리 많지 않을 듯해
남들이 자동해 해놓은 것 때문에 우쭐해
있어
그건 꽁짜로 얻을 수 있는 것이지
But I think it bares repeatingall the code you won’t be needing,when you hook it up in IB.

인터페이스 빌더에서 연결하기만 하면
똑같은 코드를 반복해서 만들지 않아도 되지
자동으로 해주니깐

Model View - it even handles multiple selections tooModel View Controller

모델뷰 여러군데를 선택한 것도 처리해 주네
모델 뷰 컨트롤러

Model View - hope I get my G5 before youModel View Controller

모델 뷰 분명히 남들보다 먼저 완성할거야모델 뷰 컨틀롤러
Yeah, yeah, yeah. Yeah.

예예예예


댓글 없음:

댓글 쓰기