<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=TellVsAsk</id>
	<title>TellVsAsk - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=TellVsAsk"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=TellVsAsk&amp;action=history"/>
	<updated>2026-05-16T00:17:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://mediawiki.zeropage.org/index.php?title=TellVsAsk&amp;diff=39603&amp;oldid=prev</id>
		<title>imported&gt;Unknown at 05:28, 7 February 2021</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=TellVsAsk&amp;diff=39603&amp;oldid=prev"/>
		<updated>2021-02-07T05:28:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;원문 : http://www.pragmaticprogrammer.com/ppllc/papers/1998_05.html 중 &amp;#039;Tell vs Ask&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 Alec Sharp, in the recent book Smalltalk by Example [SHARP], points up a very valuable lesson in few words: &lt;br /&gt;
   &lt;br /&gt;
 Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. &lt;br /&gt;
    --- Alec Sharp&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;then 에서 than 이 되어야 하는 것이 아닐까요? 제가 원문을 못봐서 함부로 고치기는 힘들군요.&amp;#039;&amp;#039;&lt;br /&gt;
      &amp;#039;&amp;#039;맞는 지적인데. 원문도 then 이군. 내가 해석을 than 으로 읽고 실수했네. Thanks.~&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
아랙 샤프의 &amp;quot;Smalltalk by Example&amp;quot; 이라는 최근의 책에서는 아주 값어치있는 교훈을 강조한다.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;절차적인 코드에서는 정보를 얻고 난 뒤 할 일을 결정한다. 개체 지향 코드에서는 객체에게 행동을 하도록 시킨다.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 That is, you should endeavor to tell objects what you want them to do; do not ask them questions about their state, &lt;br /&gt;
 make a decision, and then tell them what to do. &lt;br /&gt;
&lt;br /&gt;
요는, 당신은 객체들로 하여금 당신이 원하는 일을 하도록 노력해야 한다. 객체들의 상태에 대해 객체들에게 묻지 말고, 결정하라. 그리고 객체들에게 원하는 일을 하도록 하라. &lt;br /&gt;
&lt;br /&gt;
 The problem is that, as the caller, you should not be making decisions based on the state of the called object &lt;br /&gt;
 that result in you then changing the state of the object. The logic you are implementing is probably the called object&amp;#039;s &lt;br /&gt;
 responsibility, not yours. For you to make decisions outside the object violates its encapsulation. &lt;br /&gt;
문제점은 caller 로서, 당신은 called object 의 상태에 기반한 결정을 내리면 안된다는 것이다. &lt;br /&gt;
당신이 구현하려는 logic 은 아마도 호출된 객체의 책임이지, 당신의 책임이 아니다. (여기서 you 는 해당 object 를 이용하는 client. caller) 당신이 object 의 바깥쪽에서 결정을 내리는 것은 해당 object 의 encapsulation 에 위반된다.&lt;br /&gt;
&lt;br /&gt;
 Sure, you may say, that&amp;#039;s obvious. I&amp;#039;d never write code like that. Still, it&amp;#039;s very easy to get lulled into &lt;br /&gt;
 examining some referenced &lt;br /&gt;
 object and then calling different methods based on the results. But that may not be the best way to go about doing it. Tell the object &lt;br /&gt;
 what you want. Let it figure out how to do it. Think declaratively instead of procedurally! &lt;br /&gt;
아마 당신은 이렇게 말할지도 모른다. &amp;quot;나는 그런 코드를 작성한 적이 없어!&amp;quot; 하지만, referenced object 의 값을 조사해서 그 결과값에 따라 각각 다른 메소드를 호출하는 식으로 적당히 구현하며 얼머무리는 경우는 흔하다.&lt;br /&gt;
&lt;br /&gt;
exam) 아마 Refactoring 책에도 나올것이지만.&lt;br /&gt;
 switch (person.gender) {&lt;br /&gt;
 	case IS_MALE:&lt;br /&gt;
 		____&lt;br /&gt;
 	case IS_FEMALE:&lt;br /&gt;
 		____&lt;br /&gt;
 }&lt;br /&gt;
이런식의 코드들. 보통 이런건 Polymorphism 으로 해결해야 할 문제들이지요.&lt;br /&gt;
&lt;br /&gt;
하지만, 이는 좋은 방법이 아니다. 당신이 원하는 일에 대해서 object 에게 시켜라. (즉, 저 행위에 대한 결정은 object 내에서 해결하게끔) object 로 하여금 어떻게 해야 할지 해결하도록 하라. 절차적이려하기 보단, 서술적이려고 하라. (이는 OOP 에서 이야기하듯, Object 들 간의 행동들에 대해서.)&lt;br /&gt;
&lt;br /&gt;
 It is easier to stay out of this trap if you start by designing classes based on their responsibilities, &lt;br /&gt;
 you can then progress naturally to specifying commands that the class may execute, as opposed to queries &lt;br /&gt;
 that inform you as to the state of the object. &lt;br /&gt;
만일 당신이 각 클래스들의 책임에 기반한 디자인으로 시작했다면 이러한 함정에 탈출하는 일은 쉽다.&lt;br /&gt;
(ResponsibilityDrivenDesign) 그러한 경우, 당신은 당신에게 객체의 상태를 알리도록 질의문을 작성하는 대신 (주로 getter 들에 해당되리라 생각), class 들이 실행할 수 있는 &amp;#039;&amp;#039;&amp;#039;command&amp;#039;&amp;#039;&amp;#039; 들을 자연스럽게 발전시켜 나갈 것이다.&lt;br /&gt;
&lt;br /&gt;
만약 그들의 책임(의미)에 기반해서 클래스 설계를 시작한다면 이런한 덫에서 벗어나기에 더 쉽다.&lt;br /&gt;
----&lt;br /&gt;
Reference - Smalltalk By Example 중 &amp;#039;Tell, Don&amp;#039;t Ask&amp;#039; (http://www.iam.unibe.ch/~ducasse/WebPages/FreeBooks.html 에 공개되어있다.)&lt;br /&gt;
----&lt;br /&gt;
See also [http://www.owlnet.rice.edu/~comp212/99-fall/handouts/week1/person 개체지향vs절차지향]  - 지금 여기 서버가 죽은것 같은데 서버 살아나면 페이지 뜰껍니다...;; - 임인택&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>