﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-我的隐式生活（My Implicit Life）-文章分类-&lt;b&gt;-=Design Pattern=-&lt;/b&gt;</title><link>http://www.blogjava.net/marco/category/7334.html</link><description>&lt;b&gt;继续搞“对象”，玩OO.&lt;/b&gt;
</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 03:33:42 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 03:33:42 GMT</pubDate><ttl>60</ttl><item><title>惊现 bruce eckel 的一句猛话！</title><link>http://www.blogjava.net/marco/articles/67163.html</link><dc:creator>marco</dc:creator><author>marco</author><pubDate>Fri, 01 Sep 2006 09:16:00 GMT</pubDate><guid>http://www.blogjava.net/marco/articles/67163.html</guid><wfw:comment>http://www.blogjava.net/marco/comments/67163.html</wfw:comment><comments>http://www.blogjava.net/marco/articles/67163.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/marco/comments/commentRss/67163.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/marco/services/trackbacks/67163.html</trackback:ping><description><![CDATA[
		<p>The interfaces that are concerned with holding objects are <b>Collection</b>, <b>List</b>, <b>Set</b>, and <b>Map</b>.<b></b>Ideally, you’ll write most of your code to talk to these interfaces, and the only place where you’ll specify the precise type you’re using is at the point of creation. So you can create a <b>List</b> like this: <br /></p>
		<blockquote>
				<font size="+1">
						<pre>List x = <font color="#0000ff">new</font> LinkedList();</pre>
				</font>
		</blockquote>
		<p>
				<br />
		</p>
		<p>Of course, you can also decide to make <b>x </b>a <b>LinkedList </b>(instead of a generic <b>List</b>)<b></b>and carry the precise type information around with <b>x</b>.<font color="#ff0000"><u> The beauty (and the intent) of using the <b>interface</b> is that if you decide you want to change your implementation, all you need to do is change it at the point of creation, like this:<br /></u></font></p>
		<blockquote>
				<font size="+1">
						<pre>List x = <font color="#0000ff">new</font> ArrayList();</pre>
				</font>
		</blockquote>
		<p>
				<br />
		</p>
		<p>
				<font color="#ff0000">
						<u>The rest of your code can remain untouched (some of this genericity can also be achieved with iterators).</u>
				</font>
				<br />
				<br />操。以前怎么就没人这么讲过呢。妈的，都是垃圾！</p>
<img src ="http://www.blogjava.net/marco/aggbug/67163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/marco/" target="_blank">marco</a> 2006-09-01 17:16 <a href="http://www.blogjava.net/marco/articles/67163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>