⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 架构性宣言midp2_0中的工厂设计模式-开发者网络-midp-天极yesky.htm

📁 j2me的一些东西。有用的东东
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://dev.yesky.com/191/2351191.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>架构性宣言:MIDP2.0中的工厂设计模式-开发者网络-MIDP-天极Yesky</TITLE>
<META content=架构性宣言:MIDP2.0中的工厂设计模式, name=description>
<META content=架构性宣言:MIDP2.0中的工厂设计模式, name=keywords>
<META content="天极Yesky | 全球中文IT第一门户" name=author>
<META content="天极Yesky | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all 
href="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/y_mobile_content.css" 
type=text/css rel=stylesheet>
<SCRIPT src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/showlay.js"></SCRIPT>

<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A 
href="http://product.yesky.com/">产品报价</A>| <A 
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A> 
| <A href="http://digital.yesky.com/">数码</A> | <A 
href="http://notebook.yesky.com/">笔记本</A> | <A 
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A> 
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A> 
| <A href="http://dh.yesky.com/">数字家庭</A> | <A 
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> | 
<A href="http://e.yesky.com/">e时代</A> | <A href="http://game.yesky.com/">游戏</A> 
| <A href="http://pic.yesky.com/">图片</A> | <A 
href="http://desktop.yesky.com/">壁纸</A> | <A href="http://q.yesky.com/">群乐</A> | 
<A href="http://my.yesky.com/">社区</A> | <A href="http://blog.yesky.com/">博客</A> 
| <A href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A href="http://www.yesky.com/"><IMG alt=天极Yesky_全球中文IT第一门户 
src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/logo.gif" border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get 
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select() 
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden 
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A 
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广东</A> <A 
href="http://xa.yesky.com/">西安</A><BR><A href="http://cq.yesky.com/">重庆</A> <A 
href="http://cd.yesky.com/">成都</A> <A href="http://sy.yesky.com/">沈阳</A> <A 
href="http://js.yesky.com/">江苏</A> </DIV>
<DIV class=rightarea_right><A 
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/content_text_ad.js" 
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/flash.js" 
type=text/javascript></SCRIPT>

<DIV id=childmenu><A href="http://soft.yesky.com/">软件频道&gt;</A><A 
href="http://dev.yesky.com/">程序开发&gt;</A><A 
href="http://dev.yesky.com/devjava/">Java</A><A 
href="http://dev.yesky.com/ysdevvb">VB</A><A 
href="http://dev.yesky.com/ysdevvc">VC</A><A 
href="http://dev.yesky.com/ysdevdelphi">Delphi</A><A 
href="http://dev.yesky.com/ysdevc">C/C++</A><A 
href="http://dev.yesky.com/web/">Web开发</A><A 
href="http://dev.yesky.com/msdn/">微软专栏</A><A 
href="http://dev.yesky.com/devydkf/">移动</A><A 
href="http://dev.yesky.com/devsjk/">数据库</A><A 
href="http://dev.yesky.com/ysdevcxrs">程序人生</A><A 
href="http://dev.yesky.com/ysdevrjgc">软件工程</A>|<A 
href="http://soft.yesky.com/lesson/">产品中心</A><A 
href="http://www.mydown.com/soft/develop/news.shtml">下载</A><A 
href="http://q.yesky.com/group/179"><FONT 
color=#ff0000>群乐:大家耍QQ</FONT></A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/">天极Yesky</A> &gt; <A 
href="http://soft.yesky.com/">软件频道</A> &gt; <A 
href="http://dev.yesky.com/">开发者网络</A> &gt; 架构性宣言:MIDP2.0中的工厂设计模式</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/191/2351191.shtml#pls" 
target=_self>评论</A></DIV>
<DIV class=kr></DIV>
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
</DIV></DIV></DIV>
<DIV class=topadbg><SPAN id=ad10></SPAN></DIV><A name=top></A>
<DIV id=contitle>
<H1>架构性宣言:MIDP2.0中的工厂设计模式</H1></DIV>
<DIV id=conauthor><SPAN>2006-03-29 08:54 </SPAN><SPAN>作者: mikko </SPAN><SPAN>出处: 
ibm </SPAN><SPAN>责任编辑:<A title=向本编辑提问 
href="http://comments.yesky.com/t/·&frac12;&Ouml;&Ucirc;/6,324/2351191.shtml" target=_blank>方舟</A> 
</SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<DIV class=guanggao><SPAN id=contentAdv></SPAN></DIV>   手机开发人员通常使用 Generic 
Connection Framework 在 Mobile Information Device Profile (MIDP) 
中创建和维护顺利的连接。好的架构师都知道该框架背后真正的动力是不可缺少的工厂设计模式。工厂设计模式是面向对象编程所必需的,它构成了应用程序开发人员使用的大多数强大框架的基础 
—— 包括 MIDP。在本月的<I>架构性声明</I> 专栏中,我将介绍工厂模式的三种变体,然后展示如何在 MIDP 2.0 
通用连接框架中工厂支持连接处理。<BR><BR><STRONG>  工厂模式</STRONG><BR><BR>  工厂设计模式是面向对象编程中最常用的设计模式之一。它又被称为<I>创建性模式</I>,因为它被用来创建其他类。在应用程序预见不到自己要创建的对象类型时,就会使用工厂解决方案。在这些情况下,可以使用工厂模式作为创建对象的基础,不需要确切地了解将要创建哪些对象。 
<BR><BR><I>  工厂</I> 实际上是一组模式的名称,这组模式的目的是创建类。每个变体都指定一个不同的创建方法。这些模式变体是:<BR>
<UL>
  <LI>静态工厂(Static Factory) 
  <LI>工厂方法(Factory Method) 
  <LI>抽象工厂(Abstract 
Factory)</LI></UL>  首先,我先一般性地查看一下工厂模式解决常见应用程序设计问题的方式。然后将演示工厂模式如何开始对 MIDP 2.0 
中大量连接类型的连接进行处理。<BR><BR>  <STRONG>基于工厂的解决方案</STRONG><BR><BR>  不管使用哪种变体,所有的工厂模式都是通过将应用程序从将要初始化的类中隔离出来进行启动,实现方法是插入一个 
factory 类来做实际的创建工作。图 1是工厂模式的结构图。可以看到,Client 是需要创建新实例的应用程序或类,Product 
是需要创建的类;Factory 是实际创建产品的类。 <BR><BR><B>图 1. 工厂设计模式的结构</B><BR><IMG height=114 
alt=工厂设计模式的结构 
src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/xbc3b8994x4d.gif" 
width=237><BR><BR>  图 2是工厂模式使用方式的概述,其中的工厂可以创建两种产品。<BR><BR><B>图 2. 
静态工厂模式的实现</B><BR><IMG height=315 alt=静态工厂模式的实现 
src="架构性宣言MIDP2_0中的工厂设计模式-开发者网络-MIDP-天极Yesky.files/6k59719qk851.gif" 
width=459><BR><BR>  客户机使用工厂类中的不同方法来创建 ProductA 和 ProductB 
的实例。该模式的优点在于,只要工厂接口可用,客户机就不需要考虑如何创建对象。例如,客户机只需要调用以下代码,就可以创建 ProductA 
类的实例。<BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e3e3e3 border=1>
  <TBODY>
  <TR>
    <TD><PRE>ProductA p = Factory.createA();</PRE></TD></TR></TBODY></TABLE>
<DIV class=right>共3页。 <A class=page 
href="http://dev.yesky.com/191/2351191.shtml" target=_self><FONT 
color=#666666><B>1</B></FONT></A> <A class=page 
href="http://dev.yesky.com/191/2351191_1.shtml" target=_self><B>2</B></A> <A 
class=page href="http://dev.yesky.com/191/2351191_2.shtml" 
target=_self><B>3</B></A> <A class=page 
href="http://dev.yesky.com/191/2351191_1.shtml" target=_self><FONT 
face=Webdings>8</FONT></A> <A class=page 
href="http://dev.yesky.com/191/2351191_2.shtml" target=_self><FONT 
face=Webdings>:</FONT></A></DIV></DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 412;
}
</SCRIPT>
<!--小通栏:c-scolumn顶部500*90--><SPAN id=span_ad1>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-scolumn.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad1").innerHTML=document.getElementById("span_ad1").innerHTML;
document.getElementById("span_ad1").innerHTML="";
</SCRIPT>
<!--c-pip文章正文中间240*200--><SPAN id=span_ad3>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-pip.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT>
if(document.getElementById("contentAdv")) {
document.getElementById("contentAdv").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
} else {
document.getElementById("ad3").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
}</SCRIPT>
<!--c-text-1“您现在的位置”右侧文字--><SPAN id=span_ad2>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-text-1.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad2").innerHTML=document.getElementById("span_ad2").innerHTML;
document.getElementById("span_ad2").innerHTML="";
</SCRIPT>
<!--c-column-2“标题”上面的广告--><SPAN id=span_ad10>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-column-2.js\"><\/script>");</SCRIPT>
</SPAN>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -