??xml version="1.0" encoding="utf-8" standalone="yes"?>精品国产一区二区三区不卡,午夜影视日本亚洲欧洲精品 ,69视频在线播放http://www.aygfsteel.com/yglwxl/category/31645.htmlzh-cnSun, 13 Feb 2011 21:19:57 GMTSun, 13 Feb 2011 21:19:57 GMT60Observer模式在J2EE中的实现 [http://35java.com/zhibo/forum.php?mod=viewthread&tid=108&extra=page%3D3]http://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.html九宝九宝Sun, 13 Feb 2011 11:24:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.htmlhttp://www.aygfsteel.com/yglwxl/comments/344203.htmlhttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344203.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/344203.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/344203.html引言Q?/span>
            设计模式是经验的文化。它是对被用来在特定场景下解决一般设计问题的cd怺通信的对象的描述。更通俗的来_它是一个问?解决Ҏ寏V一旦我们掌握了设计模式Q就{于拥有了一支强有力的专安伍。它甚至能够佉K向对象的新手利用前h的经验找责明的cd对象Q从而获得优雅的解决Ҏ。由于设计模式也是重构的目标Q如果在设计的初期适当地引入设计模式,可以减少重构的工作量?/span>
      但是Q我们也不能陷入模式的陷阱,Z使用模式而去套模式,那样会陷入Ş式主义。我们在使用模式的时候,一定要注意模式的意图(intentQ,而不要过多的d注模式的实现l节Q因些实现细节在特定情况下,可能会发生一些改变。不要顽固地认ؓ设计模式一书中的类图或实现代码׃表了模式本n?/span>
      下面Q我们来讨论一下ؓ什么要在分布式、多层系l中使用Observer模式?/span>
      

多层体系l构Qmulti-tier architectureQ:
            三层体系l构是多层体pȝ构中最单的一U,它一般包括:
      
  • 表示?presentation)Q窗口、报?
  • 业务逻辑?business logic)Q管理业务过E的d和规则。它又可以细分ؓ领域对象层(代表领域概念Q和服务层(提供数据库交互、安全性、打印报表)?/li>
  • 存储?storage)Q持久化存储机制。如数据库服务器{?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " />
              
图一Q三层体pȝ?/strong>
              
      而Java 2q_企业版(J2EEQ是一U利用Java 2q_来简化诸多与多企业解决Ҏ的开发、部|和理相关的复杂问题的体系l构。它是开攄、基于标准的q_Q用以开发、部|和理N层结构、面向Web的,以服务器Z心的企业U应用?/span>
      Z支持领域对象的复用,q且佉K域对象的接口变更所带来的媄响最化。我们将领域层(模型Q和表示层(视图Q相分离?/span>
      采用模型Q视图模式的意义在于Q?/span>
      
  • 支持聚合度更高的模型定义Q模型的定义可以集中在领域q程的定义,而不是图形界面上?/li>
  • 允许模型和用户界面q行开发?/li>
  • 使用L面的需求变化对领域层所造成的媄响最化?/li>
  • 允许建立与一个现有的领域层对象相q接的新视图Q同时不影响领域层?/li>
  • 允许一个模型同时有多个视图Q例如用SVG和表根{?/li>
  • 允许模型层独立于用户界面层执行?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; word-wrap: break-word; " />
      而这恰恰与Observer模式的意囄d。因此我们有必要跨层来实现Observer模式?/span>
      其实Q在应用中更多的是采用MVC框架来架构整个企业应用的。在MVC框架中,Model和View之间存在着依赖关系Q是Observer模式的典型应用。当然MVC框架q包括其它模式如Composite模式和Strategy模式。在J2EEq_中,我们可以把Web TierQ包括Jsp和servelet和JavaBeanQ看作是表示层,EJB Tier看作是领域层。而controller可能跨距Web Tier?EJB Tier?/span>
      在Javacd中采用Java.util.ObservablecdJava.util.Observer接口来实现Observer模式Q它们在单个的Java VM.中运行的很好Q但如果惛_EJB中用它们就会有一些问题。这正如我们引言中提到的Q模式的具体实现在特定情况下Q可能会发生一些改变?/span>
      

g递还是远E引用传递?
                    g递:        
在Java RMI中要求所有的参数和返回类型是JAVA的基本类型或实现Java.io.Serilizable的对象。串行化对象通过g递(又名拯传递)Q而不是引用传递,q意味着在某一层中串行化对象的更ƈ不自动媄响到其它的对象?nbsp;     
              q程引用传递:        
对于EJB对象而言Q它׃个接口(home接口和remote接口Q和一个类l成。容器会Ҏejb规范来生成实C面两个接口的c(我们分别UCؓxxxEJBHome对象和xxxEjbObject对象Q。在较多的容器的实现Ҏ中,xxxEJBHome对象使用了factory模式来创建xxxEjbObject对象QxxxEjbObject对象则采用proxy模式Q作为xxxBean的代理类。在生成以上两个对象的同Ӟ容器会从部v文g中读取关于安全、事务、持久性等服务q在xxxEjbObject对象和xxxEJBHome对象中添加以上服务的代码。而且xxxEJBHome对象和xxxEjbObject对象都是分布式对象,我们在此只讨论xxxEjbObject对象。所谓分布式对象Q从本质上来Ԍ分ؓ3个部分:object server、skeleton、stub。其中object server和skeleton位于服务器端Q而stub位于客户端。Object server负责实现业务逻辑Qskeleton负责marshal和unmarshalҎ{֐?nbsp;     
              
图二Q分布式对象
              
      昄QEJB的客P调用EJB的对象)可以是Q何对象,包括EJB和一般的Javacȝx用Q何语a写的corba客户端?/span>
      从EJB的客戯角来看的话,我们只能看到一个home接口、一个remote接口Q对于实体bean的话Q还可以看见一个主键类Q而beancd客户是不可见的)。但我们从上面的Q我们可以知道,对于remote接口中地Ҏ调用Q实际上是多态地调用XXX_StubcR即XXX_Stub对象对客户具有可见性(但这U可见性是透明的,卛_户不知道q种可见性的存在Q。由于,XXX_Stub对象和Object Server实现了相同的接口Qƈ且Object server真正实现了业务逻辑。所以,当在客户端调用XXX_Stub对象的方法时候,XXX_Stub对象通过socket通信机制方法签名传lXXX_Skeleton对象QXXX_Skeleton对象在去委托Object Server完成业务处理逻辑。因此,Object Server本n发生了改变。我们称XXX_Stub对象是Object Server对象的远E引用,q认为当分布式对象作为参C递的时候,是通过引用传递的Q会产生副作?/span>

九宝 2011-02-13 19:24 发表评论
]]>
JavaBean PropertyChange 之设计模式Observer(?http://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.html九宝九宝Sun, 13 Feb 2011 10:26:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.htmlhttp://www.aygfsteel.com/yglwxl/comments/344201.htmlhttp://www.aygfsteel.com/yglwxl/archive/2011/02/13/344201.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/344201.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/344201.html阅读全文

九宝 2011-02-13 18:26 发表评论
]]>
(?UML中类囑֮?/title><link>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html</link><dc:creator>九宝</dc:creator><author>九宝</author><pubDate>Sat, 12 Feb 2011 05:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html</guid><wfw:comment>http://www.aygfsteel.com/yglwxl/comments/344130.html</wfw:comment><comments>http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/yglwxl/comments/commentRss/344130.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/yglwxl/services/trackbacks/344130.html</trackback:ping><description><![CDATA[<span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">接口Q空心圆+直线Q唐老鸭cdC‘讲h?#8217;Q;<br style="line-height: 22px; " /> 依赖Q虚U?头Q动物和I气的关p)Q?br style="line-height: 22px; " /> 兌Q实U?头Q企鹅需要知道气候才q移Q;<br style="line-height: 22px; " /> 聚合Q空心四边Ş+实线+头Q雁和大雁的关p)Q?br style="line-height: 22px; " /> 合成/l合Q实心四边Ş+实线+头Q鸟和翅膀的关p)Q?br style="line-height: 22px; " /> 泛化/</span></span><span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">l承</span></span><span style="font-size: 15px; line-height: 22px; "><span style="line-height: normal; word-spacing: 0px; font: normal normal normal 14px/22px georgia; text-transform: none; color: #4b4b4b; text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; text-align: left; orphans: 2; widows: 2; ">Q空心三角Ş+实线Q动物和鸟的l承关系Q;<br style="line-height: 22px; " /> 实现Q空心三角Ş+虚线Q实现大雁飞的接口Q; <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "></div> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><strong style="line-height: 22px; ">UMLcd</strong>  </div> <dl style="line-height: 22px; "><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" height="670" src="http://hiphotos.baidu.com/liang125353769/pic/item/b70db9225fc72a0393580758.jpg" width="703" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; border-right-width: 0px; " alt="" /></div> 解释</span><span style="line-height: 22px; ">UML<span style="line-height: 22px; ">cdQ?/span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">1.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">首先?#8220;动物”矩Ş框,它代表一个类。该cd分ؓ三层Q第一层显C类的名Uͼ如果是抽象类p用斜体显C。第二层是类的特性,通常是字段和属性。第三层是类的操作,通常是方法和行ؓ?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">   注意前面的符P‘</span>+<span style="line-height: 22px; ">’表示</span>public, ‘<span style="line-height: 22px; ">?/span>’<span style="line-height: 22px; "> </span><span style="line-height: 22px; ">表示</span>private, ‘#’<span style="line-height: 22px; ">表示</span>protected.   </div> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/48598af20714951d342acc58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" />                                           </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">2.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span>“<span style="line-height: 22px; ">飞翔</span>”<span style="line-height: 22px; ">矩Ş框表CZ个接口图Q它与类囄区别主要是顶端有?/span>interface<span style="line-height: 22px; ">》显C,W一行是接口名称Q第二行是接口方法。接口还有另一U表C方法,俗称棒p表C法Q就是唐老鸭cdC“讲h?#8221;的接口?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" height="159" src="http://hiphotos.baidu.com/liang125353769/pic/item/2f017cbee612fc4718d81f58.jpg" width="500" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" />              </div> </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">interface</span><span style="line-height: 22px; color: #000000; "> IFly                              </span><span style="line-height: 22px; color: #0000ff; ">interface</span><span style="line-height: 22px; color: #000000; "> Ilanguage                              <br style="line-height: 22px; " /> {                                              {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">void</span><span style="line-height: 22px; color: #000000; "> Fly();                                   <span style="line-height: 22px; "> </span></span><span style="line-height: 22px; color: #0000ff; ">void</span><span style="line-height: 22px; color: #000000; "> Speak();<br style="line-height: 22px; " /> }                                             }</span></div> </div> </div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">3.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">动物Q鸟Q鸭Q唐老鸭他们之间都是l承的关p,<span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">l承关系用空心三角Ş</span>+<span style="line-height: 22px; ">实现来表C?/span></span></span><span style="line-height: 22px; ">?/span>   </div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/92d8300b954bc073b0351d58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div>                  </div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">4.“大雁”实现?#8220;飞翔”接口?span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">实现接口?/span><span style="line-height: 22px; ">I心三角?/span>+<span style="line-height: 22px; ">虚线来表C?/span></span></span><span style="line-height: 22px; ">。(<span style="line-height: 22px; background-color: yellow; ">注:下面的图中应为空心三角Ş</span>Q?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/7cd2161f3a40815240341758.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Bird:Animal                      </span><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> WideGoose:IFly<br style="line-height: 22px; " /> {                                        {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">l承动物c?nbsp;                                </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">实现飞翔接口</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}                                        }</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">5.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">企鹅与气候有很大的关p,企鹅需?#8220;知道”气候的变化Q需?#8220;了解”气候规律。当一个类“知道”另一个类Ӟ可以用关?/span>(association)<span style="line-height: 22px; ">关系?span style="line-height: 22px; color: red; ">兌关系用实U箭头来表示</span>?/span><span style="line-height: 22px; ">  </span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">     <img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/568a4d1ed5a7eb47314e1558.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Penguin :Bird<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> Climate climate;</span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在企鹅Penguin中,引用到气候Climate对象</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">6.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“大雁”?#8220;雁群”q两个类。大雁是居动物Q每只大雁都属于一个雁,一个雁可以有多只大雁。所以它们之间就满聚合</span>(Aggregation)<span style="line-height: 22px; ">关系?span style="line-height: 22px; color: red; "><span style="line-height: 22px; background-color: yellow; "><span style="line-height: 22px; color: #000000; "><span style="line-height: 22px; font-size: 10.5pt; ">聚合表示一U弱?#8220;拥有”关系Q体现的?/span><span style="line-height: normal; ">A</span><span style="line-height: 22px; font-size: 10.5pt; ">对象可以包含</span><span style="line-height: normal; ">B</span><span style="line-height: 22px; font-size: 10.5pt; ">对象Q但</span><span style="line-height: normal; ">B</span><span style="line-height: 22px; font-size: 10.5pt; ">对象不是</span><span style="line-height: normal; ">A</span><span style="line-height: 22px; font-size: 10.5pt; ">对象的一部分?/span></span></span></span></span><span style="line-height: 22px; "><span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">聚合关系用空心的菱Ş</span>+<span style="line-height: 22px; "> </span><span style="line-height: 22px; ">实线头表示</span></span></span><span style="line-height: 22px; ">?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; ">    <span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/6b9361c93d15b55a7e3e6f58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> <br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> WideGooseAggregate<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> WideGoose[] arrayWideGoose;<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在雁WideGooseAggregatecMQ有大雁数组对象arrayWideGoose</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">}</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">7.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“?#8221;?#8220;膀”q两个类。鸟和翅膀似整体和部分的关p,q且膀和鸟的生命周期是相同的,在这里鸟和其膀是合成关系?span style="line-height: 22px; background-color: yellow; "><span style="line-height: 22px; ">合成</span>(composition)<span style="line-height: 22px; ">是一U强?#8220;拥有”关系Q体C严格的部分和整体的关p,部分和整体的生命周期一?/span></span></span><span style="line-height: 22px; ">?span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">合成关系用实心的的菱?/span>+<span style="line-height: 22px; ">实线头来表C?/span></span></span><span style="line-height: 22px; ">。另外,合成关系的连U两端还有一个数?#8220;</span>1<span style="line-height: 22px; ">”和数?#8220;</span>2<span style="line-height: 22px; ">”Q,q被UCؓ基数。表明这一端的cd以有几个实例Q很昄Q一个鸟应该有两支翅膀。如果一个类可能有无C实例Q则q“</span>n<span style="line-height: 22px; ">”来表C。关联关p,聚合关系也可以有基数的?/span></div> </dt></dl><dl style="line-height: 22px; "><dt style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/59df7916e3ad1b44c83d6d58.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Bird <br style="line-height: 22px; " /> {<br style="line-height: 22px; " />   </span><span style="line-height: 22px; color: #0000ff; ">private</span><span style="line-height: 22px; color: #000000; "> Wing wing;<br style="line-height: 22px; " />   </span><span style="line-height: 22px; color: #0000ff; ">public</span><span style="line-height: 22px; color: #000000; "> Bird()<br style="line-height: 22px; " />    {<br style="line-height: 22px; " />       wing</span><span style="line-height: 22px; color: #000000; ">=</span><span style="line-height: 22px; color: #0000ff; ">new</span><span style="line-height: 22px; color: #000000; "> Wing();<br style="line-height: 22px; " />     </span><span style="line-height: 22px; color: #008000; ">//</span><span style="line-height: 22px; color: #008000; ">在鸟BirdcMQ初始化Ӟ实例化翅膀Wing,它们之间同时生成</span><span style="line-height: 22px; color: #008000; "><br style="line-height: 22px; " /> </span><span style="line-height: 22px; color: #000000; ">   }<br style="line-height: 22px; " /> }</span></div> </dt><dt style="line-height: 22px; "><br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; ">8.<span style="line-height: normal; ">      <span style="line-height: 19px; "> </span></span><span style="line-height: 22px; ">“动物”?#8220;氧气”?#8220;?#8221;之间。动物有几大特征Q比如有新陈代谢Q能J殖。而动物要有生命,需要氧气,水以及食物等。也是说动物依赖于氧气和水。它们之间是<span style="line-height: 22px; color: red; "><span style="line-height: 22px; ">依赖关系</span>(Dependency),<span style="line-height: 22px; ">用虚U箭头来表示</span></span></span><span style="line-height: 22px; ">?/span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "><span style="line-height: 22px; "><span style="line-height: 22px; color: #0000ff; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><img title="UML中类囑֮?- Doom - 风云掠过" src="http://hiphotos.baidu.com/liang125353769/pic/item/8167d70857ae0c823ac76358.jpg" style="line-height: 22px; border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; max-width: 100%; cursor: pointer; border-right-width: 0px; " alt="" /></div> </span></span></div> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; margin-left: 18pt; text-indent: -18pt; "></div> <br style="line-height: 22px; " /> </dt><dt style="line-height: 22px; "> <div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 22px; "><span style="line-height: 22px; color: #0000ff; ">abstract</span> <span style="line-height: 22px; color: #0000ff; ">class</span><span style="line-height: 22px; color: #000000; "> Animal<br style="line-height: 22px; " /> {<br style="line-height: 22px; " />    </span><span style="line-height: 22px; color: #0000ff; ">public</span><span style="line-height: 22px; color: #000000; "> bolism(Oxygen oxygen,Water water)<br style="line-height: 22px; " />     {<br style="line-height: 22px; " />     } <br style="line-height: 22px; " /> }</span></div> </dt></dl></span></span> <img src ="http://www.aygfsteel.com/yglwxl/aggbug/344130.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/yglwxl/" target="_blank">九宝</a> 2011-02-12 13:02 <a href="http://www.aygfsteel.com/yglwxl/archive/2011/02/12/344130.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Bitwise operators and Shift operatorshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.html九宝九宝Tue, 20 May 2008 05:22:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.htmlhttp://www.aygfsteel.com/yglwxl/comments/201630.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201630.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201630.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201630.html 按位q行与运?Q?&
按位q行或运?Q?|
按位q行位异q算Q?^
按位q行取反q算Q?~
按位q行循环左移Q?lt;<Q运符左侧对象左移由右侧指定的位数Q低位补0Q最高位抛弃。带W号的左UMq算相当于对左操作数q行?q算?
按位q行循环右移Q?gt;>Q运符左侧对象右移由右侧指定的位数Q若gؓ正,在最高位插入0Q若gؓ负,在最高位插入1Q即Ud的最高位和原最高符号位相同。带W号的右UMq算相当于对左边的运对象进行除2q算?
按位q行无符号右U:>>>Q无符左边的运对象取值正负,都在高位插入0Q即Ud位始l补0.
要注意是没有按位q行无符号左Uȝ。位q算W的操作数只能是整数Qchar,byte,short,
int和long,q行位运时QL先将字符型倹{字节型值和短整型D{换ؓ整型再进行位q算。位q算W游标的操作数用于指定移动的位数Q按规定其不应超q左侧数的进制表CZ数?
The bitwise operators allow you to manipulate individual bits in an integral primitive data type.Bitwise operators perform Boolean algebra on the corresponding bits in the two arguments to produce the result. The bitwise operators come from C’s low-level orientation, where you often manipulate hardware
directly and must set the bits in hardware registers. Java was originally designed to be embedded in TV set-top boxes, so this low-level orientation still made sense. However, you probably won’t use the bitwise operators much.
The bitwise AND operator (&) produces a one in the output bit if both input bits are one; otherwise, it produces a zero.
The bitwise OR operator (|) produces a one in the output bit if either input bit is a one and produces a zero only if both input bits are zero.
The bitwise EXCLUSIVE OR, or XOR (^), produces a one in the output bit if one or the other input bit is a one, but not both.
The bitwise NOT (~, also called the ones complement operator) is a unary operator; it takes only one argument. (All other bitwise operators are binary operators.) Bitwise NOT produces the opposite of the input bit—a one if the input bit is zero, a zero if the input bit is one.

九宝 2008-05-20 13:22 发表评论
]]>
Special case: primitive typeshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.html九宝九宝Tue, 20 May 2008 05:12:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.htmlhttp://www.aygfsteel.com/yglwxl/comments/201623.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201623.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201623.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201623.htmlSpecial case: primitive types

Java determines the size of each primitive type. These sizes don’t change from one machine

architecture to another as they do in most languages. This size invariance is one reason Java

programs are more portable than programs in most other languages.

 

 

All numeric types are signed, so don’t look for unsigned types.

The size of the boolean type is not explicitly specified; it is only defined to be able to take the literal values true or false.

The “wrapper” classes for the primitive data types allow you to make a non-primitive object on the heap to represent that primitive type. For example:

char c = 'x';

Character ch = new Character(c);

Or you could also use:

Character ch = new Character('x');

Java SE5 autoboxing will automatically convert from a primitive to a wrapper type:

Character ch = 'x';

and back:

char c = ch;

The reasons for wrapping primitives will be shown in a later chapter.

High-precision numbers

Java includes two classes for performing high-precision arithmetic: BigInteger and

BigDecimal. Although these approximately fit into the same category as the “wrapper” classes, neither one has a primitive analogue.

Both classes have methods that provide analogues for the operations that you perform on

primitive types. That is, you can do anything with a BigInteger or BigDecimal that you can with an int or float, it’s just that you must use method calls instead of operators. Also, since there’s more involved, the operations will be slower. You’re exchanging speed for accuracy.

BigInteger supports arbitrary-precision integers. This means that you can accurately represent integral values of any size without losing any information during operations.

BigDecimal is for arbitrary-precision fixed-point numbers; you can use these for accurate

monetary calculations, for example.

 

OX123Q?/span>1×162Q?/span>2×161Q?/span>3×160



九宝 2008-05-20 13:12 发表评论
]]>
整型数据http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.html九宝九宝Tue, 20 May 2008 05:10:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.htmlhttp://www.aygfsteel.com/yglwxl/comments/201617.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/201617.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/201617.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/201617.html 1.十进?br /> 2.八进Ӟ以o开头O123Q?×82Q?×81Q?×80Q十q制?3
3.十六q制 Q以ox开?nbsp; OX123Q?/span>1×162Q?/span>2×161Q?/span>3×160



九宝 2008-05-20 13:10 发表评论
]]>
Introduction to Objectshttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.html九宝九宝Tue, 20 May 2008 05:10:00 GMThttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.htmlhttp://www.aygfsteel.com/yglwxl/comments/199515.htmlhttp://www.aygfsteel.com/yglwxl/archive/2008/05/20/199515.html#Feedback0http://www.aygfsteel.com/yglwxl/comments/commentRss/199515.htmlhttp://www.aygfsteel.com/yglwxl/services/trackbacks/199515.html1.The hidden implementation
The goal of the class creator is to build a class that exposes only what is necessary to the client programmer and keeps everything else hidden. Why?
(1)Becuase if it is hidden, the client programmer can't access it, which means that the class creator can change the hidden portion at will withou worring about the impact on anyone else.
(2)The hidden portion usually reprsents the tender insides of an object that could easily be corrupted by a careless or uninformed client programmer, so hiding the implementation reduces program bugs.

2.Reusing the implementation
The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this "creating a member object." Your new class can be made up of any mumber and type of other objectss, in any combination that you need to achieve the fuctionality desired in your new class. Because you are composing a new class from existing classes, this conception is called composition. Compositon is often referred to as a "has-a" relationship, as "A car has an engine."
Because inheritance is so important in OOP, it is often highly emphasized, and the new programmer can get the idea that inheritance should be used everywhere. This can result in awkward and overly complicated designs. Instead, you should first look to composition when creating new classes, since it is simpler and more flexible. If you take this approach,your designer will be cleaner. Once you have had some experience, it will be reasonably obvious when you need inheritance.

3.Inheritance
You have two ways to differentiate your new derived class from the original base class.
The first is quite straightforward: You simply add brand new methods to the derived class. This means that the base class simply didn't as much as you wanted it to, so you added more methods. This simple and primitive use for inheritance is, at times, the perfect solution to your problem. However, you should look closely for the posiblilty that your base class might also need these additional methods. This process of discovery and iteration of your design happens regularly in OOP.
The second and more important way to differentiate your new class is to change the behavior of an existing base-class method. This is referred to as overriding that method. To override a method, you simply create a new definition for the method in the derived class. You are saying, "I am using the same interface method here, but I want it to do something different for my new type."

4.Is-a vs. is-like-a relationships

5.Interchangeable objects with polymorphism

6The single rooted hierarchy
All objects have a single rooted hierarchy can be guaranteed to have certain functionality. You know you can perform certain basic operations on every object in your system. All objects can easy be created on the heap, and argument passing is greatly simplified.
A single rooted hierarchy makes it much easier to implement a garbage collector, which is one of the fundamental improvements of Java over C++. And since information about the type of an object is guaranteed to be in all objects, you'll never end up with an object whose type you cannot determine. This is especially important with system-level operations, such as exception handling, and to allow greater flexibility in programming.

7.Containers

8.Parameterized types(generics)
One of the big changes in Java SE5 is the addition of parameterized types, called generics in java. you will recongize the use of generics by angle brackets with types inside.

9.Object creation & lifetime
How can you possibly know when to destroy the objects?
(1).C++ takes the approach that control of efficiency is the most important issue, so it give the programmer a choice.
(2).Java, in heap

10 Exception handling: dealing with errors

























九宝 2008-05-20 13:10 发表评论
]]>
java bytecdZ么是Q?27—?Q?28Q?/title><link>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html</link><dc:creator>九宝</dc:creator><author>九宝</author><pubDate>Tue, 20 May 2008 04:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html</guid><wfw:comment>http://www.aygfsteel.com/yglwxl/comments/201595.html</wfw:comment><comments>http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/yglwxl/comments/commentRss/201595.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/yglwxl/services/trackbacks/201595.html</trackback:ping><description><![CDATA[所有的整数cdQ除了char cd之外Q都是有W号的整?br /> <br /> 因ؓQ?java的byte?bitQ位Q,是8?/1 来表C?br /> 但是W一位是W号位,表示正数q是负数。所以:<br /> 0000 0001表示1Q?nbsp;    Q?×  <span style="font-size: 10.5pt; font-family: Georgia">2<sup>0</sup></span>Q?br /> 0000 0000表示0Q?nbsp;    Q?×  <span style="font-size: 10.5pt; font-family: Georgia">2<sup>0</sup></span>Q?br /> <br /> 计算Z负数的二q制码是是负数的l对值取反,然后?.<br /> 例如Q?的二q制Q?br /> Q?的绝对值是1Q?000 0001Q?<br /> 取反是(1111 1110Q?<br /> 再加 1Q?000 0001 Q;<br /> l果是(1111 1111Q?br /> <br /> 要对一个负数的二进制进行解码,首先对其所有的位取反,然后??br /> 例如Q??nbsp;二进?nbsp;  Q?111 1111Q?br /> 取反Q?nbsp; 0000 0000 ?<br /> 再加1Q(0Q?Q?Q?br /> W号位是1Q是负数Q所以是Q?<br /> <br /> 1000 0000 表示Q?28Q?nbsp;  Q解码过E:位取反是0111 1111Q=?27Q然后加1Q=?28Q符号位?,是负敎ͼ表示Q?28Q?br /> <br /> <img src ="http://www.aygfsteel.com/yglwxl/aggbug/201595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/yglwxl/" target="_blank">九宝</a> 2008-05-20 12:48 <a href="http://www.aygfsteel.com/yglwxl/archive/2008/05/20/201595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">߷</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨ǰ</a>| <a href="http://" target="_blank">J</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɳƺ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Զ</a>| <a href="http://" target="_blank">ǿ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ؼ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ұ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">½</a>| <a href="http://" target="_blank">ӱʡ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>