??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品亚洲片在线花蝴蝶,亚洲精品免费网站,亚洲另类图片另类电影http://www.tkk7.com/jayliu/We are extremely fortunate not to know precisely the kind of world we live in zh-cnSun, 11 May 2025 20:35:20 GMTSun, 11 May 2025 20:35:20 GMT60提高工作效率之利?--- 十大在线d理|站http://www.tkk7.com/jayliu/archive/2010/08/05/328066.htmlq?/dc:creator>q?/author>Thu, 05 Aug 2010 13:42:00 GMThttp://www.tkk7.com/jayliu/archive/2010/08/05/328066.htmlhttp://www.tkk7.com/jayliu/comments/328066.htmlhttp://www.tkk7.com/jayliu/archive/2010/08/05/328066.html#Feedback2http://www.tkk7.com/jayliu/comments/commentRss/328066.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/328066.html阅读全文

]]>
CentOS5.3完美配置http://www.tkk7.com/jayliu/archive/2009/05/01/268462.htmlq?/dc:creator>q?/author>Fri, 01 May 2009 01:40:00 GMThttp://www.tkk7.com/jayliu/archive/2009/05/01/268462.htmlhttp://www.tkk7.com/jayliu/comments/268462.htmlhttp://www.tkk7.com/jayliu/archive/2009/05/01/268462.html#Feedback0http://www.tkk7.com/jayliu/comments/commentRss/268462.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/268462.html因ؓ文章较长Q一共六)׃一一贴出来了Q请点击下面的链接查看详情:

Centos 5.3服务器完设|(一Q?/a>

Centos 5.3服务器完设|(二)

Centos 5.3服务器完设|(三)

Centos 5.3服务器完设|(四)

Centos 5.3服务器完设|(五)

Centos 5.3服务器完设|(六)





]]>
Java Collection框架Q你可能不知道的一些小知识http://www.tkk7.com/jayliu/archive/2009/04/08/264407.htmlq?/dc:creator>q?/author>Wed, 08 Apr 2009 02:28:00 GMThttp://www.tkk7.com/jayliu/archive/2009/04/08/264407.htmlhttp://www.tkk7.com/jayliu/comments/264407.htmlhttp://www.tkk7.com/jayliu/archive/2009/04/08/264407.html#Feedback0http://www.tkk7.com/jayliu/comments/commentRss/264407.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/264407.htmlQ原文发表于http://www.ondev.net/post/show/565Q{载请注明出处Q?br />
关于Java Collection FrameworkQ你可能已经知道如下一些事?

  1. Vector是线E安全的QArrayList不是
  2. ArrayList的读操作比LinkedList快,LinkedList的append操作比ArrayList?
  3. Set中不可能有两个相{的元素Q也是_如果e1和e2都在同一个Set中,那么不可能有e1.equals(e2)
  4. HashMap是线E不安全的,HashTable是线E安全的


但是你可能还不知道或者不了解q些事情Q?/p>

  1. LinkedList不是U程安全?
  2. 不管是在多线E还是单U程的环境下QArrayList都要比Vector快很多?
  3. Set中可以插入nullQ不q最多只会有一?
  4. HashMap中可以插入nullQHashTable中不?
  5. TreeSet使用compareTo代替equals判断是否两个元素相等
  6. HashMap中的元素Q无论是keySetq是valueSetQ都不一定是按照插入旉先后排序的,HashSet也一?
  7. 对于非线E安全的c,比如HashMapQArrayListQTreeSetQ可以用Collections.synchronizedXXXҎQ比如synchronizedSetQsynchronizedList,synchronizedMap)
  8. 你可以用Collections.unmodifiableList来构建出一个不能被修改的List
  9. 你可以用Arrays.equals来判断两个数l是否相{?
  10. WeakHashMap使用元素的引用而不是g为keyQ也是说必d引用相同Qa==bQ的情况下才能找到相关的?
  11. 对于WeakHashMapQ一旦引用失效,相应的g׃存在了,比如下面一D代码中Q?

 
  1. public   class  TestHashMap {    
  2.   
  3.      public   static  WeakHashMap wHmp=  new  WeakHashMap();    
  4.        
  5.      public   static   void  main(String args[]){    
  6.        String s1 =  new  String( "one" );    
  7.        wHmp.put(s1, new  Integer( 1 ));    
  8.        addObject(wHmp);    
  9.        Set setHmp= wHmp.keySet();    
  10.            
  11.         for (Iterator it=setHmp.iterator();it.hasNext();){    
  12.           System.out.println(wHmp.get(it.next()));    
  13.       }    
  14.            
  15.    }    
  16.        
  17.     public   static   void  addObject(WeakHashMap wHmp){    
  18.            
  19.      String s2 =  new  String( "two" );    
  20.      String s3 =  new  String( "three" );    
  21.      wHmp.put(s2, new  Integer( 2 ));    
  22.      wHmp.put(s3, new  Integer( 3 ));    
  23.      s2= null ;    
  24.      s3= null ;    
  25.      System.gc();    
  26.    }    
  27. }   

最后打印出来的l果只有"one?/p>

]]>
使用Grails和Rome产生Rsshttp://www.tkk7.com/jayliu/archive/2008/09/06/227394.htmlq?/dc:creator>q?/author>Sat, 06 Sep 2008 05:42:00 GMThttp://www.tkk7.com/jayliu/archive/2008/09/06/227394.htmlhttp://www.tkk7.com/jayliu/comments/227394.htmlhttp://www.tkk7.com/jayliu/archive/2008/09/06/227394.html#Feedback0http://www.tkk7.com/jayliu/comments/commentRss/227394.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/227394.html阅读全文

]]>
在tomcat中用jconsole http://www.tkk7.com/jayliu/archive/2008/08/15/222137.htmlq?/dc:creator>q?/author>Fri, 15 Aug 2008 00:50:00 GMThttp://www.tkk7.com/jayliu/archive/2008/08/15/222137.htmlhttp://www.tkk7.com/jayliu/comments/222137.htmlhttp://www.tkk7.com/jayliu/archive/2008/08/15/222137.html#Feedback1http://www.tkk7.com/jayliu/comments/commentRss/222137.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/222137.html

需要添加如下参敎ͼ

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.port=8086

-Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false

启动JConsole以后会要求选择q接Q切换到Remote标签port?086可以了

 

举例Q?/p>

catalina.bat?

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

Q本文也发表?a >http://www.ondev.net/story/show/49Q{载请注明出处Q?/p>

]]>
SWT/Jface开发入门指?十一) http://www.tkk7.com/jayliu/archive/2005/11/06/18399.htmlq?/dc:creator>q?/author>Sun, 06 Nov 2005 05:09:00 GMThttp://www.tkk7.com/jayliu/archive/2005/11/06/18399.htmlhttp://www.tkk7.com/jayliu/comments/18399.htmlhttp://www.tkk7.com/jayliu/archive/2005/11/06/18399.html#Feedback7http://www.tkk7.com/jayliu/comments/commentRss/18399.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/18399.htmlJFace中的工具条和菜单

前一节中我们单介l了一?/SPAN>Action。其实所谓的Action是一个最常用的事Ӟ举个例子来说Q对于一个按钮来说它可以有多个事Ӟ比如按键Q焦点,鼠标Q等{等{吧Q但是实际上在用程序的时候,我们最兛_的,是按下去这个按钮会发生什么,q个其实是所谓的Action。如果大家以前做q?/SPAN>swing/awt变成的话Q应该对Action不会陌生?/SPAN>

?/SPAN>JFace里面Q一?/SPAN>Action可以对应多个GUI对象Q这些对象就是所谓的Contribution Item。比如我们在一般程序里面很常见的“文件”菜单,下面都会有“新建”,“保存”等{。同时我们可以在工具条上攄相应的按钮,那么q些都是有相同的功能Q在JFace里面我们可以只写一?/SPAN>ActionQ然后把它映到不同?/SPAN>ContributionItem去,而不必ؓ每个部g都写一串处理事件?/SPAN>

我们下面q是通过一个简单的例子来说明,?/SPAN>JFace中怎么使用菜单和工hq两U最基本也是最有用?/SPAN>Contribution Item?/SPAN>

我们q个E序写得很傻Q就是一个光U秃的窗口上做了一个菜单和工具条按钮,功能也只有一个,是每次点一下,弹Z个输入框来问你名字是什么,然后昄一?/SPAN>Hello, xxx之类的?/SPAN>

首先我们q是来写一?/SPAN>Actionc:

 1 
 2 public class SayHiAction extends Action {
 3     private Shell shell;
 4 
 5     public SayHiAction(Shell shell) {
 6         super();
 7         this.shell = shell;
 8         this.setText("Say&Hi@Ctrl+H");
 9     }
10 
11     @Override
12     public void run() {
13         InputDialog input = new InputDialog(shell, "Input your name",
14                 "Please input your name here:"nullnull);
15         if (input.open() == Window.OK) {
16             MessageDialog.openInformation(shell, "Hello""Hello, "
17                     + input.getValue() + "!");
18         }
19 
20     }
21 
22 }
23 



代码D?/SPAN> 17

q只是一个很单的Actionc,没有太多可说的?/SPAN>

然后我们创徏一?/SPAN>ApplicationWindowc:

 1 
 2 public class Hiyou extends ApplicationWindow {
 3 
 4     private SayHiAction hiaction;
 5     public Hiyou(Shell parentShell) {
 6         super(parentShell);
 7         hiaction=new SayHiAction(getShell());
 8         addMenuBar();
 9         addToolBar(SWT.FLAT | SWT.WRAP);
10     }
11 
12     @Override
13     protected ToolBarManager createToolBarManager(int style) {
14         ToolBarManager toolbar=new ToolBarManager();
15         toolbar.add(hiaction);
16         return toolbar;
17     }
18 
19     @Override
20     protected MenuManager createMenuManager() {
21         MenuManager menubar=new MenuManager();
22         MenuManager fileMenu=new MenuManager("&File");
23         fileMenu.add(hiaction);
24         menubar.add(fileMenu);
25         return menubar;
26     }
27 
28     /**
29      * @param args
30      */
31     public static void main(String[] args) {
32         Hiyou window=new Hiyou(null);
33         window.setBlockOnOpen(true);
34         window.open();
35         Display.getCurrent().dispose();
36     }
37 
38 }
39 

 

代码D?/SPAN> 18

大家可能已经注意CQ在q里面我们重载了createMenuManager?/SPAN>createToolBarManager两个ҎQ它们的用途就和名字一P一个是用来创徏菜单的,一个是用来创徏工具条的。重载了q两个方法以后,通过在构造函C调用addMenuBar?/SPAN>addToolBar让工h和菜单显C出来?/SPAN>

q里值得一提的?/SPAN>MenuManager?/SPAN>ToolBarManagerc,如果大家M?/SPAN>API文档的话会发现它们都是所谓的contribution managerQ实CIConntributionManager接口Q,你可以通过q些contribution manager来实现对特定lg的管理(d删除{等Q?/SPAN>

具体到菜单的创徏Q看了我们上面的代码很明白了,q接调用相?/SPAN>MenuManager?/SPAN>addҎ?/SPAN>actiond上就可以了?/SPAN>JFace会自动找到这?/SPAN>Action?/SPAN>getTextҎ讄菜单的文字。如果是有好几层菜单Q那么只要在重新new一?/SPAN>MenuManagerd到已有的MenuManager里面可以了。就象前面代码中的:

menubar.add(fileMenu);



至于工具条就更简单了Q创Z?/SPAN>ToolBarManager然后直接add对应?/SPAN>Action可以了?/SPAN>

d图标

如果菜单只是文字q没有什么,如果你的工具条都是文字是不是会显得干巴巴的?其实只要我们?/SPAN>ActionImageDescriptor可以了Q比如你可以自己M个图标保存到Action的包下面Q我M一?/SPAN>hi.gifQ,然后?/SPAN>Action的构造函数改写成q样Q?BR>

public SayHiAction(Shell shell) {
        
super();
        
this.shell = shell;
        
this.setText("Say&Hi@Ctrl+H");
        
this.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(),
                
"hi.gif"));
    }



大家注意最后一句话Q就是ؓaction讄图标的。然后再q行一下就会发现菜单和工具栏都有图标了?/SPAN>

l束?o:p>

q一pd的文章陆陆箋l写C天,也就写完了。回头看一下,虽然内容都很显Q不q我觉得?/SPAN>swt?/SPAN>JFace中文资料~Z的今天,可能也可以给大家带来一些启q。今后我q会写一?/SPAN>eclipseq_开发的文章Q大家可以登陆到我的blogQ?/SPAN>http://blog.csdn.net/jayliuQ查看?/SPAN>

另外大家也可以登陆到在中?/SPAN>EclipseC֌Q?/SPAN>http://www.eclipseworld.orgQ,在那里你也可以找到很多的帮助和支持,当然Q你也可以在那里扑ֈ我?/SPAN>



]]>
SWT/Jface开发入门指??http://www.tkk7.com/jayliu/archive/2005/10/14/15537.htmlq?/dc:creator>q?/author>Fri, 14 Oct 2005 09:42:00 GMThttp://www.tkk7.com/jayliu/archive/2005/10/14/15537.htmlhttp://www.tkk7.com/jayliu/comments/15537.htmlhttp://www.tkk7.com/jayliu/archive/2005/10/14/15537.html#Feedback6http://www.tkk7.com/jayliu/comments/commentRss/15537.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/15537.htmlJFace中的事g模式

大家好,因ؓ工作的事情搞了一个多月,现在l于暂时安定下来了。这一pd的文章我也会l箋往下写?/SPAN>

在这一节中Q我会向大家介绍JFace中的事g模式。其实我怿q篇文章的读者应该大部分都会接触eclipseQ这样可能也会接触过eclipse的插件开发。就是没有接触过Q大家也可能会有?/SPAN>eclipse里面新徏工程的时候出于各U原因(比如好奇心)点了plug-in project的时候吧。其实作Z个程序员来讲Q保持好奇是很重要的。如果你大概看过一?/SPAN>plug-in project的结构,虽然可能不能全部理解Q但是我怿也应该对Action之类有一些了解。我们这一节主要就是围l?/SPAN>Action来写的。ؓ了增加可L,我们首先介绍几个名词Q这些名词都可以?/SPAN>eclipse的文中扑ֈ?/SPAN>

什么是Action

JFace中的一?/SPAN>Action可以单地理解成一?SPAN style="COLOR: blue">命o。那么它?SPAN style="COLOR: blue">事g有什么关pdQ比如说我点了一个菜单,那么点击本n是一个事Ӟ但是q个事g的媄响就是相应的命o被执行了。大家日怋用的一些Y件比?/SPAN>Office都是有菜单和工具栏的Q而一个菜单项和一个工h可能执行的是同一个命令。比?/SPAN>Word里面要新Z个文的话可以通过?/SPAN>文g?/SPAN>菜单下的?/SPAN>新徏?/SPAN>实现Q也可以通过点击工具栏上相应的图标实现。这个新建地功能本n?/SPAN>JFace里面是可以?/SPAN>Action来实现的?/SPAN>

?/SPAN>JFace里面Q?/SPAN>Action可以兌到菜单,工具条,以及按钮Q也是ButtonQ。当然关于如何关联,我们会在后面向大家详l介l?/SPAN>

Action?/SPAN>JFace里面的定义是一个接?/SPAN>org.eclipse.jface.action.IAction。当然实际上你写E序的时候必自己来实现q个接口Q写qActioncL?/SPAN>

IAction里面最重要的方法是run()Q它也是事g触发以后执行的代码。其他的Ҏ都是一些辅助性的ҎQ不是我们要x的重炏Vؓ了能够将_֊集中在我们所x的事情上Q通常我们不是实现IAction接口Q而是通过l承org.eclipse.jface.action.Actionq个抽象cL实现Action。下面我们通过一个例子来说明Action的用法?BR>

Hello,Action!

首先我们先不用L面,先定义一个最单的ActioncR?BR>

 1 public class HelloAction extends Action{
 2     private Shell shell;
 3     
 4     public HelloAction(Shell shell) {    
 5         super("&Hello",Action.AS_PUSH_BUTTON);
 6         this.shell=shell;
 7     }
 8 
 9 
10     @Override
11     public void run() {
12         MessageDialog.openInformation(shell, "Hello""Hello,Action!");
13     }
14     
15 }
16 


代码D?/SPAN> 15

q段代码其实应该q是很好L的。带参的构造函数带q来一?/SPAN>Shell实例Q?/SPAN>run()Ҏ说明了这?/SPAN>Action的功能就是显CZ个对话框。第5行中的代码调用了父类的构造函敎ͼ其中W一个参数是Action对应的文本,前面?/SPAN>&W号表明?/SPAN>H是热键,而第二个参数则是一个风格参数。如果大家l向后看的话Q就会发现这?/SPAN>Action被附加在了一个按钮上面,而按钮上昄的文本就?/SPAN>HelloQ如果你定义的风g?/SPAN>AS_PUSH_BUTTON而是AS_RADIO_BUTTON的话׃发现按钮已经不是一个纯_的按钮了,而是一个单选钮。相应的其他风格可以参照Javadoc?BR>

 1 
 2 public class HelloJface extends ApplicationWindow {      
 3     public HelloJface(Shell shell) {
 4         super(shell);
 5     }
 6       @Override
 7     protected Control createContents(Composite parent) {
 8           HelloAction action=new HelloAction(parent.getShell());
 9           ActionContributionItem aci=new ActionContributionItem(action);
10           aci.fill(parent);
11           return parent;
12    }  
13    /**
14     * @param args
15     */
16    public static void main(String[] args) {
17 
18        HelloJface demo = new HelloJface(null);
19        demo.setBlockOnOpen(true);
20        demo.open();
21        Display.getCurrent().dispose();
22 
23    }
24 }


代码D?/SPAN> 16

和前面一节的代码相比Q我们只是修改了createContentsҎ。首先创Z一?/SPAN>HelloAction的实例,然后又创Z一?/SPAN>ActionContributionItem的实例,最后调用了q个实例?/SPAN>fillҎ按钮添加到H口中,q就是全部了。是不是很简单呢Q程序运行出来的效果如下图:

r_helloaction.JPG

?/SPAN> 16

可能看了q个例子Q你会认?/SPAN>ActionContributionItemq个c表C的是一个按钮了。但是实际上q不是的Q它在图形界面上表示成什么样子,随着不同?/SPAN>fill调用又有不同。在下一节中Q我会向大家深入介绍Contribution Item以及JFace中的菜单Q工h{的应用。这一节就到这里结束了Q因为刚刚换了工作环境,有很多事情需要去做,所以写得比较短Q请大家见谅Q)?/SPAN>

 



]]>
在WebLogic中用Hibernatehttp://www.tkk7.com/jayliu/archive/2005/07/11/7516.htmlq?/dc:creator>q?/author>Mon, 11 Jul 2005 11:17:00 GMThttp://www.tkk7.com/jayliu/archive/2005/07/11/7516.htmlhttp://www.tkk7.com/jayliu/comments/7516.htmlhttp://www.tkk7.com/jayliu/archive/2005/07/11/7516.html#Feedback3http://www.tkk7.com/jayliu/comments/commentRss/7516.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/7516.html阅读全文

]]>
J2SE5.0新特?--变长参数(Varargs)http://www.tkk7.com/jayliu/archive/2005/05/22/5055.htmlq?/dc:creator>q?/author>Sun, 22 May 2005 08:46:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/22/5055.htmlhttp://www.tkk7.com/jayliu/comments/5055.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/22/5055.html#Feedback0http://www.tkk7.com/jayliu/comments/commentRss/5055.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/5055.html变长参数Q?/SPAN>VarargsQ?/SPAN>

与泛型一P变长参数?/SPAN>C++中有?/SPAN>Java中没有的一U语aҎ,在过d果我们想向一个函C递可变数量的函数Q就必须首先这些参数放入一个数l中Q然后将数组传递给函数。就如同下面所作的一P

Object[] arguments = { 640, "kb", "anybody", "Bill Gates" };

String result = MessageFormat.format(

                   "{3}:{0,number,integer}{1} ought to be enough for {2}  ",

                   arguments);

 

?/SPAN>J2SE5.0中,参数仍然是被攑օ一个数l中传给对应的方法,但是不同的是Q你不再需要手动的创徏数组Q而是只需要将那些参数|列出来Q其他的工作p拟机替你完成。所以现在我们可以这样写Q?/SPAN>

String result = MessageFormat.format(

                                     "{3}:{0,number,integer}{1} ought to be enough for {2}  ",

                                     640, "kb", "anybody", "Bill Gates");

 

我们通过一个示例函数来说明使用变长参数函数的定义。这个函数打印出一个hȝ几条狗的名字?/FONT>

private void printDogNames(String... dogs)

{

         System.out.println("I have " + dogs.length + " dogs:");

         for(String dogname:dogs)

         {

                   System.out.println(dogname);

         }

}

 

事实上变长参?/SPAN>dogs是一个数l?/SPAN>

一个函数的参数中只能有一个变长参敎ͼ所以类g面的定义?SPAN style="COLOR: red">不合?/SPAN>的:

private void printDogNames(String... dogs,float... dogage)

 

如果军_把函数参数设|ؓ可变长度的,你必L到这样一U情况,是调用的程序很可能会不l你传Q何的参数Q这个时候作为参数的数组length?/SPAN>0Q而这在语法上是完全合法的Q所以你必须在函数定义中考虑到这U情c?/SPAN>

 



]]>
SWT/Jface开发入门指南(三) http://www.tkk7.com/jayliu/archive/2005/05/19/4875.htmlq?/dc:creator>q?/author>Thu, 19 May 2005 09:33:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/19/4875.htmlhttp://www.tkk7.com/jayliu/comments/4875.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/19/4875.html#Feedback5http://www.tkk7.com/jayliu/comments/commentRss/4875.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/4875.html阅读全文

]]>
SWT/Jface开发入门指南(二)http://www.tkk7.com/jayliu/archive/2005/05/18/4460.htmlq?/dc:creator>q?/author>Wed, 18 May 2005 02:35:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/18/4460.htmlhttp://www.tkk7.com/jayliu/comments/4460.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/18/4460.html#Feedback4http://www.tkk7.com/jayliu/comments/commentRss/4460.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/4460.html?/SPAN>Hello, world!开始了?/SPAN>Display?/SPAN>Shell

在这一节中Q我们从前面所列D出来?/SPAN>Hello, world!E序开始对swtq行一些初步的探烦。所谓的初步是指Q我们会介绍~写swtE序的基本思\Q以及对两个重要的类:Display?/SPAN>Shell作一些介l?BR>

因ؓq一节和前一节是分成两个部分贴出来的Q所以我仍然?/SPAN>Hello, world!的代码段在下面列出来Q?/SPAN>

 1package swtjfacesample;
 2
 3import org.eclipse.swt.SWT;
 4import org.eclipse.swt.widgets.Display;
 5import org.eclipse.swt.widgets.Shell;
 6import org.eclipse.swt.widgets.Text;
 7
 8public class HelloSwt {
 9    /**
10     * Hello,world!
11     * 
12     * @param args
13     */

14       public static void main(String[] args) {
15        Display display = new Display();
16        Shell shell = new Shell(display);
17        
18        Text helloText = new Text(shell, SWT.CENTER);
19        helloText.setText("Hello,World!");
20        helloText.pack();
21        
22        shell.pack();
23        shell.open();
24
25        while (!shell.isDisposed()) {
26            if (!display.readAndDispatch()) {
27                display.sleep();
28            }

29        }

30        display.dispose();
31
32    }

33}


代码D?/EM> 2

q段E序虽然很简单,但是它反映了我们书写swtE序的步骤,q些步骤是:

1.      创徏一?/SPAN>Display对象

2.      创徏一个或者多?/SPAN>Shell对象Q你可以认ؓShell代表了程序的H口?/SPAN>

3.      ?/SPAN>Shell内创建各U部ӞwidgetQ?/SPAN>

4.      对各个部件进行初始化Q外观,状态等Q,同时为各U部件的事g创徏监听器(listenerQ?/SPAN>

5.      调用Shell对象?/SPAN>open()Ҏ以显C窗?/SPAN>

6.      各种事gq行监听q处理,直到E序发出退出消?/SPAN>

7.      调用Display对象?/SPAN>dispose()Ҏ以结束程序?/SPAN>

 

?/SPAN>Hello,world!E序中,Z让程序更加简单,我们没有创徏事g监听器,在以后的内容中会q行专门介绍?/SPAN>

现在让我们稍微深入一些,看一下这?/SPAN>Display,Shell有什么作用以至于我们每个E序都必L它们存在?/SPAN>

Display:与操作系l沟通的桥梁

我们在前面说q,每个swtE序在最开始都必须创徏一?/SPAN>Display对象?/SPAN>Display对象起什么作用呢Q它?/SPAN>swt与操作系l沟通的一座桥梁。它负责swt和操作系l之间的通信。它?/SPAN>swt/JFace的各U调用{化ؓpȝ的底层调用,控制操作pȝ?/SPAN>swt分配的资源。同时我们也可以通过Display对象得到操作pȝ的一些信息?/SPAN>

Display是一?/SPAN>?/SPAN>q后工作?/SPAN>?/SPAN>Q它?/SPAN>swt/JFace提供支持Q但是你q不能够从某个用L面中看到它的影子?/SPAN>

在前面的Hello,world!E序中,我们可以看到构徏一?/SPAN>Display对象是和普通的Java对象一样通过构造函数实现的。它为实现图形界面准备了最基本的条件。而在E序l束时我们必L式地调用dispose() Ҏ来释攄序运行中所获得的资源。一般来_一个程序只需要一?/SPAN>Display对象Q当然没有h止你创建多?/SPAN>Display对象。但是在swt?/SPAN>javadoc中,我们可以看到关于q个问题一些描qͼ

“Applications which are built with SWT will almost always require only a single display. In particular, some platforms which SWT supports will not allow more than one active display. In other words, some platforms do not support creating a new display if one already exists that has not been sent the dispose() message.?o:p>

Display有着众多的方法,我们不可能一一介绍。在q里只挑选几个可能会比较常用的作一些简单介l?/SPAN>

l         setData()?/SPAN>getData()Q这一对函数允许我们ؓDisplay对象讑֮一些数据,setData()的参Ckey?/SPAN>valuecM于我们在使用Map对象?/SPAN>key?/SPAN>value的含义?/SPAN>

l         getShells()得到兌到该Display对象的所有没?/SPAN>dispose?/SPAN>Shell对象

l         getCurrent()得到与用户交互的当前U程

l         readAndDispatch()得到事gq且调用对应的监听器q行处理

l         sleep(){待事g发生

Shell:H口

一?/SPAN>Shell对象是一个窗口。你可以在上面放|各U部件创Z富的囑Ş界面?/SPAN>

我们都知道窗口有很多U,比如H口有可以调整大的Q有不可以的Q有的没有最大化最化按钮。这些窗体的特征?/SPAN>swt中被成ؓ风格Q?/SPAN>styleQ。一个窗体的风格可以用一个整数进行定义。这些风格的定义?/SPAN>org.eclipse.swt.SWT中?/SPAN>

Shell对象可用的风格包括:BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE , PLICATION_MODAL, MODELESS, PRIMARY_MODAL,S YSTEM_MODAL

q些风格我们不作一一介绍Q你可以从他们字面意义看Z些含义来Q当然也可以参考对应的javadoc?/SPAN>

我们可以在一?/SPAN>Shell的构造函C定义它的风格Q比如在前面?/SPAN>Hello,world!E序中,我们可以q样定义Shell?/SPAN>

 

Shell shell = new Shell(display,SWT.CLOSE | SWT.SYSTEM_MODAL);

 

最后得到的H体没有最大化和最化按钮Qƈ且大是固定不变的?/SPAN>

因ؓswtq行于各U^C上,而这些^C的窗口管理器千差万别Q所以所有这些风格都不是肯定可以实现的。在swt?/SPAN>javadoc中,q被UCؓ暗示Q?/SPAN>hintsQ?/SPAN>

Shell对象的方法大都和GUI有关Q比?/SPAN>setEnabled()讑֮了窗体是否能够和用户q行交互Q?/SPAN>setVisble()讑֮了窗体是否可见,setActive()窗体设为当前的zdH口?/SPAN>

我们可以?/SPAN>open()Ҏ打开一个窗体,close()Ҏ关闭一个窗体?/SPAN>

本节讨论?/SPAN>Display?/SPAN>Shell的一些概念,q是我们以后q一步了?/SPAN>swt的基。在下一节中Q我介l各U部ӞwidgetQ的用法Q所谓部Ӟ是指文本框,标签{?/SPAN>UI实体?/SPAN>



]]>
SWT/Jface开发入门指南(一Q?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/17/4389.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Tue, 17 May 2005 00:45:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/17/4389.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4389.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/17/4389.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4389.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4389.html</trackback:ping><description><![CDATA[     摘要: SWT/Jface开发入门指?写在前面的话 l于军_提vW来写一关于swt和JFace~程的文章。在开始之前,我想先介l一下你能够从将要出现的q一pd文章里得C么,以及更重要的Q你不能得到什么。我们的旉是如此之重要Q以至于我们很难容忍把它费在自׃兛_的事情上?因ؓ我刚开始写Q所以到底这些文章会分成几次发布出来Q也很难讌Ӏ但是我心里大体有这样一个提UӀ也是_我打介l以下方?..  <a href='http://www.tkk7.com/jayliu/archive/2005/05/17/4389.html'>阅读全文</a><img src ="http://www.tkk7.com/jayliu/aggbug/4389.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-17 08:45 <a href="http://www.tkk7.com/jayliu/archive/2005/05/17/4389.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>准时的blog.csdn.nethttp://www.tkk7.com/jayliu/archive/2005/05/16/4326.htmlq?/dc:creator>q?/author>Mon, 16 May 2005 01:15:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/16/4326.htmlhttp://www.tkk7.com/jayliu/comments/4326.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/16/4326.html#Feedback4http://www.tkk7.com/jayliu/comments/commentRss/4326.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/4326.html

]]>
透视q代开?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/14/4283.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Sat, 14 May 2005 02:08:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/14/4283.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4283.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/14/4283.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4283.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4283.html</trackback:ping><description><![CDATA[<H1 style="MARGIN: 11pt 0cm"><FONT size=3><FONT style="BACKGROUND-COLOR: #e5e5e5"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">引子Q我们ؓ什么需要P代开发?</SPAN><SPAN lang=EN-US style="mso-fareast-font-family: 宋体"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></FONT></H1> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>我们都知道,人对于世界的认识是一主观活动,它受到各U因素的影响Q得我们不能够一下子Ҏ要认知的事物有一个清晰的了解。具体到软g开发中来,我们会发玎ͼ你很隑֜开发之前弄清楚客户所有的需求。一斚wQ客户对自己惌什么可能ƈ没有一个明的xQ这好比在买服的时候,我们在专卖店里看C个服,会觉得自qh很帅Q但是你仍然需要把它真实的I在w上才能看到实际效果Q而在你看到这件服之前,你能够仅仅凭着惌在脑里ȝ件服的样子么?</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其次QY件工业中我们讲究的是投入和出比QY件业的成本主要是人力资源的成本。这也是软g目Ҏ间特别敏感的原因。时间比计划廉一个月Q对于一个数十h的团队来说就意味着几十万的成本增加。但是又有谁能够保证自己所做的软g是完无~的呢?于是很多时候我们必d已经开发的部分q行修正Q而修正就需要时间?/SPAN> <SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">传统的开发方式下Q很多Y仉目都是在匆忙交付后发现用户不满意Q于是l修正,再次引发用户的不满意Q再ơ修正,在这样反复地拖g中,客户和Y件开发商都筋疲力?/SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们需要P代开发,是因为我们深知对事物的认知就是一个探索的q程QY件开发也是一栗在温博根{探索需?/SPAN><SPAN lang=EN-US>---</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设计前的质量》一书中提到Q?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">国W?/SPAN></CITE><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt">34</SPAN></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">Lȝ艾森豪威上曾l说q,</SPAN></CITE><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt">"</SPAN></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">计划本n什么都不是Q而编制计划的q程是一?/SPAN></CITE><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt">"</SPAN></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">。我们认同这L说法Qƈ把它推广到需求过E:</SPAN></CITE><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt"><BR></SPAN></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">     <B style="mso-bidi-font-weight: normal"> 产品什么都不是Q而开发的q程是一切?/B></SPAN></CITE><CITE><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US style="FONT-SIZE: 10.5pt"><BR></SPAN></B></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">或用另一U方式表达:</SPAN></CITE><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt"><BR></SPAN></CITE><CITE><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">      发现什么都不是Q而发现过E(探烦q程Q就是一切?SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></CITE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><CITE><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体"><o:p> </o:p></SPAN></CITE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">软g目本n的意义就在于和用户一h索他们真正需要的东西q且帮助他们实现。而这U探索,如同在第一D中我们阐述的那P需要不断的反复Q如果我们没有做好P代和反复的准备,而是希望一ơ性的把所有工作都做完q且q做得非常好Q结果可能恰恰相反?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="mso-bidi-font-style: italic"><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>我们需要P代开发,是因为我们追求Y件质量的最大化。没有h可以刉出完美无缺的东西,但是我们可以通过不断的检查和反馈Q得那些不适合的东西在早期被暴露出来,q代l予了我们这样一U检查合反馈的机Ӟ让我们不必在事情l束的时候才惊奇的发现我们所一直努力在做的东西其实是一堆废物?/FONT></SPAN></P> <H1 style="MARGIN: 11pt 0cm"><FONT size=3><FONT style="BACKGROUND-COLOR: #e5e5e5"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">实践Q正实施P代开?/SPAN><SPAN lang=EN-US style="mso-fareast-font-family: 宋体"><o:p></o:p></SPAN></FONT></FONT></H1> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事实上在业界QP代开发的观念早已l深入h心,然而有多少团队在正地实施着q代Ҏ呢?有多团队通过q代得到了他们想要的东西呢?很多人简单的把P代理解ؓ开发的分阶D进行。我们常常看到有目l理们这栯Q我们打通过</SPAN><SPAN lang=EN-US>4</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">ơP代完成Y件的开发,W一ơP代,完成需求分析和软g设计Q第二次q代Q完成多多模块的开发,W三ơ,完成其他多少模块的开发,W四ơ,配置Q部|Ԍ上线Q测试,修正软g</SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。虽然我们言必称“P代”,但是q样的P代和q去传统的瀑布型开发有多少区别Q我们又能够从这L伪P代中得到什么好处呢Q?/SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在本文以下部分将对P代开发实践中几个关键斚wq行阐述Q这几个斚w我们概括Z下关键词Q?B style="mso-bidi-font-weight: normal">变化Q周期,目标Q反馈,合作</B>?/FONT></SPAN></P> <H2 style="MARGIN: 7pt 0cm 0pt 54pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">变化</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></H2> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q代思想带给我们最重要的一个启C,是要适应变化Q要U极、主动地拥抱变化而不是拒l变?/SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在过ȝ开发中Q我们常怼拒绝变化Q以需求分析工作ؓ例,有些目l在需求分析完成后会要求用L字,{到交付Ӟ如果客户有什么意见,他们׃拿出那䆾客户已经{֭L的文件来理直气壮地说Q这是你们签字过的东西,我们做的N不是和这里所说的一样么Q?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>是的Q开发出来的可能是和需求定义文件的内容一LQ但问题是:q䆾需求定义文件上描述的内Ҏ不是真正能够帮客户实现自q价值呢Q难道我们进行Y件开发的目的是让客户在一份他们根本不清楚有什么意义的文g上签字,然后用这个来反驳用户?B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: red">真正需?/SPAN></B>么?我们在Y件立之前L会告诉用Pq个卛_开发的软g会帮助他们如何如何。我们有什么理׃ؓ我们做不到这一点而理直气壮地责备客户呢?客户亲笔{֐的需求文难道不是我们整理出来ƈ且讲解给他们听的么?</FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>如果一个Y仉目的目标是帮助客户实现某一斚w的增|但是q种增值的目的q没有达刎ͼ我们可以认个Y仉目是p|的。即使Y件厂商通过q个目辑ֈ了盈利的目的Q满腹牢骚的客户也会把自q意见传播出去。而如果Y件厂商认U事情是天经C的话Q那么它在以后的软g目中也很难帮助自己的客户实C们想要的价倹{?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>我们必须让自己具有适应变化的能力。因U变化是客户需要的Q因U变化能够让软g更能体现q价倹{我q不是说应该无条件地接受q种变化Q但是我们可以在事前p些问题和客户q行充分的讨论和沟通,让他们明白,世界L变化的,需求本w可能会变化Q而这U变化需要h力和物力的支持。让客户也能够适应自n的变化,q是非常重要的?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>软g开发中的每个h都应该对变化有着充分的准备。从事Y件业的h大都充满了自信,pȝ分析师会认ؓ自己可以把所有的需求搞清楚Q设计和开发h员会觉得他们做出来的东西完美地实C需求。所以,如果我们对一个开发h员说Q某某,你过d的这个模块不能用了,我们现在需要重新做P通常我们会得到积极或者消极地抵制?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>应该让h们认识到Q变化ƈ不是对过d作的否定Q而是着g未来Q工作更加完善的必要手Dc无论是需求,设计q是E序代码Q你不可能一ơ性就把它们做到完,而只能通过不断的修正,让它近于完。这个过E就是所谓的?B style="mso-bidi-font-weight: normal">重构</B>”?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有些团队Z保持开发的E_性,?/SPAN> <SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">“冻l需求”。所谓的ȝQ也是说在一D|间内要客h代表承诺不对已经开发中的需求进行变动。如果你打算做这件事情,首先必须意识刎ͼ需求本w就是需求,它是不会因ؓ一个承诺就真正地“冻l”了。如果目前的需求定义ƈ不能反映用户真正的愿景,在冻l的周期q去以后我们仍然需要对已经做完的工作进行修攏V当Ӟ如果需求变化太频繁Q在某些时候有必要寚w求进行冻l以便让开发更加^EI同时也给软g开发者和客户一个反思的旉。但如果是需求分析工作方法有误,那就有必要作一些检讨了?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要适应变化Q我们需要让客户和开发团队有心理上的准备Q从而能够以认真的态度来对待它。还需要有正确的方法来应对变化Q比如对变化的成本估,效果的跟t,如何快速有效的对各U变化进行反映等Q这是我们必L意的问题?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <H2 style="MARGIN: 7pt 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial"><FONT size=3>周期</FONT></SPAN></H2> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">很多人简单的把P代理解ؓ开发的分阶D进行。有些项目经理会q样_我们打算通过</SPAN><SPAN lang=EN-US>4</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">ơP代完成Y件的开发,W一ơP代,完成需求分析和软g设计Q第二次q代Q完成多多模块的开发,W三ơ,完成其他多少模块的开发,W四ơ,配置Q部|Ԍ上线Q测试,修正软g</SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。在q里Q虽然他们言必称“P代”,但是q样的P代和q去传统的瀑布型开发有多少区别Q?/SPAN> <SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>q代开发是要分周期分阶D地q行Q但是不能认为简单地把开发周期划分ؓ几个不同的阶D就是P代?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">很多人对于P代周期有一些误解,比如Q?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 75pt; TEXT-INDENT: -21pt; mso-list: l2 level1 lfo1; tab-stops: list 75.0pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>n</FONT><SPAN style="FONT: 7pt 'Times New Roman'">         </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>认ؓq代只适用于开发阶D,而需求分析和设计工作则不在此范围内?/FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 75pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo2; tab-stops: list 75.0pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>n</FONT><SPAN style="FONT: 7pt 'Times New Roman'">         </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>认ؓq代周期可以拉得很长Q比如两个月Q三个月Q甚至一个季度,半年?/FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo3; tab-stops: list 75.0pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>n</FONT><SPAN style="FONT: 7pt 'Times New Roman'">         </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>需求分析,设计Q开发,试Q部|Ԍ用户反馈Q修改当作完整的q代周期Qƈ要求在前一阶段工作完全Q或者大部分Q完成以后再q行下一步工作(q代Q?/FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在一个P代周期内Q我们可以做什么事情呢Q可以说Q所有的事情。如果你认ؓq代需要在需求分析完成之后才能开始,或者系l集成必d所有P代完成之后才可以q行Q你会获得一个真正的瀑布程开发?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>一个P代周期意味着对一些特定功能(用例Q的探烦。“探索”一词可能随情况不同而有不同的含义。对于抽象别较高,模糊E度比较高的用例Q我们需要通过和用L讨论它逐渐分解为更加清楚和清晰的用例。对于目前我们认为已l得C详细定义的需求,需要选取合适的部分q行设计和实玎ͼ通过q些部分的实玎ͼ寚w求定义和技术可行性进行反馈。对那些在上ơP代中已经开发完的模块,应该可能快速地让用hZ们的意见Q以便了解是否真正解决了用户面的问题,以及q有没有可以改进的方面,再根据这些意见安排下一阶段的工作?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>我们是否可以在开发进行之前把需求或者设计全部弄清楚呢?我认为很难。因为通常来讲Q用户对于自q需求只有一个模p的概念。让我们假设一个饮食业的例子,有一天餐厅经理把你叫入办公室_马上设计一个新的菜谱,q个菜谱是ؓ某某特定人群定制的,你要让这些h感觉色香味俱全。不q在你把配料和烹调方法都设计出来之前Q我们不打算让大厨来具体做这道菜Q我们不允许p|Q所以你的设计一定要一ơ成功,你可以用调查问卷Q用户面谈等Ҏ获取最l用L需求,但是CQ你不能dq道菜?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q样的事情你可能会觉得很滑稽Q但是在软g业,cM的事情h们却认ؓ是天l地义的?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q代允许我们开发本w也作ؓ需求探索的一部分</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q通过用户对已l实现功能的反馈我们和用户都会逐渐明白什么样的Y件是我们最l想要开发的。所以,不要{到所有(或者大部分Q的分析完了才开始开发,而是早对已l捕获到的需求进行细化,早开发,以获得反馈?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在安排P代计划时Q应该指明,q次q代的目标是什么,在结束时应达到的里程是什么。如果有d提前辑ֈ了这个里E碑Q我们可以提前结束P代,或者顺便在剩下的时间内安排其他的Q务,但是要注意这U安排的合理性,不要因ؓq个而得P代周期被廉?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在一ơP代到达所讑֮的结束日期时Q就必须审视各项d是否辑ֈ了里E碑的要求,如果有Q务没有达刎ͼ原因是什么,我们是否需要对需求和技术方案做整。对于没有达到里E碑要求的Q务,我们可以采取的办法有两种Q?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo3; tab-stops: list 75.0pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>n</FONT><SPAN style="FONT: 7pt 'Times New Roman'">         </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>剩余的工作列入下一ơP代计划中去,</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo3; tab-stops: list 75.0pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>n</FONT><SPAN style="FONT: 7pt 'Times New Roman'">         </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>本ơP代的l束旉向后延迟Q等待Q务的完成</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>前一U办法适合于有很大工作量没有完成的情况Q这可能也同时说明计划的制定有问题,在制定下ơP代计划时应该考虑对Q务完成时间进行调整。后一U办法适合剩余工作量不是很大的情况?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通常来说Q一ơP代完成以后应该有一个品的新版本可用。这也就意味着Q将集成和发布分散到每次q代中去。借助于一些自动化工具Q比?/SPAN><SPAN lang=EN-US>ant</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q,我们甚至可以做到每日构徏?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个P代周期应该有多长呢?qƈ没有一个统一的说法,而是应该视目标和可用的资源而定。但是,q代周期不宜q长Q也不宜q短。P代周期过长的话,会g~反馈的旉Q可能将许多问题隐藏或是堆积了v来。P代周期过短,会让n心疲劻I事情难有大的成效。一般来_q代周期应该?/SPAN><SPAN lang=EN-US>2-6</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">周之间。如果安排的q代周期过了两个月Q你可能必d视一下P代计划的合理性了?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>不要认ؓ下一ơP代应该和上次q代的时间差不多Q刻板地把所有P代规定一个统一的时间是一个很坏的做法。但是你可以把以前P代周期中的工作效率作Z下ơP代时间的一个依据?/FONT></SPAN></P> <H2 style="MARGIN: 7pt 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial"><FONT size=3>目标</FONT></SPAN></H2> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>一ơP代必L明确的目标:我们希望通过q次q代辑ֈ什么目的。在制定目标Ӟ应该同时考虑另外一个问题:如何查该目标是否已经达成。这是所谓的“里E碑”?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q代计划必须有明而可行的目标。明的意思是它应该是<B style="mso-bidi-font-weight: normal">可度?/B>的,不能太模p,因ؓ你很难检查一个模p的目标是否达成。比如,我们可以_q次q代的目标是?/SPAN><SPAN lang=EN-US>xxx</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">斚w的需求作q一步细化和评审Q完?/SPAN><SPAN lang=EN-US>xxx</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模块的开发以加入到Y件的下一版本中去。这L目标是明而且可行的。反q来Q如果我们这栯Q我们要通过和用L讨论明确l大部分愿景Q同时要有一个初步的开发。“绝大部分”和“初步”这L词让人感到困惑:多少是绝大部分呢Q在总量未明确的前提下Q怎么能够知道完成的确是“绝大部分”而不是“一部分”?“初步的开发”似乎告诉我们这ơ开发量比较,但是具体开发哪个部分,或者开发到什么程度,q没有指Z个明的概念?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">由此产生了一个困惑,软g目是一个不断探索的q程Q我们怎么能够明确地对未来的事情作安排呢?譬如在项目初始调查用h景时Qؓ了实现“明”的目标Q是否这样定义Q务:完成</SPAN><SPAN lang=EN-US>20%</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的用h景调查?</SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">很显Ӟ用户愿景总量到底有多我们ƈ不知道,所以在q次q代完成以后如果我们问:是否真的完成?/SPAN><SPAN lang=EN-US>20%</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而不?/SPAN><SPAN lang=EN-US>15%</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q很隑־到答案?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Z避免出现q种情况Q你必须换个角度来看问题Q比如我们可以说Q对</SPAN><SPAN lang=EN-US>xxx</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部门?/SPAN><SPAN lang=EN-US>yyy</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">部门的用户做愿景调查。在q代完成后,可以查是否这两个部门所有用L访谈Q调查都已经完成Q是否这些部门每个h都认p达了全部的意思?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>所以,如果你发现很隑֯制定的目标进行度量,那么换一个角度来看事情吧Q你可能׃扑ֈ一个合适的表达方式。如果你从所有的角度都看不到事情是可以度量的Q那么这可能意味着qg事情可能q没有到应该d施的地步Q这时你应该把它从P代计划中L。对于这U情况,有h可能会说Q那我们q次q代可做的事情就很少了,如果真是q样Q那p行一ơ小的P代吧Q可能把q次q代的工作做完了以后׃有更多的工作可以安排了?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>有些目l理在日E表上,很详l地写着Q第一ơP代,某月某日到某月某日,W二ơP代:某月某日到某月某日,W三ơP代。。。这L做法是不恰当的。因为它假设了后面几ơP代的d量,但是实际上,在前面的工作完成之前Q你很难对以后的工作得到一个明地概念。而且在这L计划上,可能q没有用于测量P代成果的里程,q样的P代最后很可能会演变成为瀑布式的开发。所以,在一ơP代完成之前,不要Ҏ着去计划下ơP代,特别是不要试囄定义下ơP代的旉Q因Zq下ơP代要做什么都q不清楚?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>Z么目标的可度量性这么重要呢Q在团队开发中Q很多信息因Zh与h的交不畅而无法得到正地反馈Q这让我们没有办法实时地掌握目的进展情况,退而求其次Q我们必阶D|地了解q些信息。如果目标难以度量,q代l束后我们很难明到底有哪些工作没有完成Q也无法看C情的问题所在?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>有些团队中会要求每个成员每天对自q工作q度以百分比的Ş式做汇报Q他们以为通过q样的方式可以确实的掌握事情的进展,但实际上q不行,因ؓ软g开发中存在很多不确定因素,有时候我们认Z情已l完成了一大半Q但是可能因为技术或者其他的原因发现q一大半工作方向是错的,q时候就要推倒重来,而且Z在汇报工作量的时候L会有一些感情的因素在里面,q就佉K些看似精的癑ֈ比打了个折扣?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>所以,我们需要更加实际和l致地划分工作,对目标的完成情况q行度量。这也是q代周期不能太长的一个原因:如果你把大量有前后关联的工作划分入一个P代周期,在设定的l束到来ӞH然发现只完成了一部分,q时候虽然亡补牢仍然可以,但是中间费了大量的人力和物力?/FONT></SPAN></P> <H2 style="MARGIN: 7pt 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial"><FONT size=3>反馈</FONT></SPAN></H2> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>一个男人在大街上走着Q他q没有发现裤子上的拉铑ַl松开了,虽然看到q个情况的h有很多,但他们有各种各样的担心,比如不想多管闲事Q怕让那个男h隑֠Q或者干脆就是想看笑话。结果就是这个hl箋I着一条敞开拉链的裤子在大街上行走?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">qg事情臛_带给我们两个启示Q?/SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q得到反馈是重要的;</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q要惛_到正的Q有价值的反馈Q你需要其他h的配合?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>对于用户需求来_没有用户及时地反馈,我们可能把那些不符合需求的开发l下去,׃软g中各U功能和模块的依赖性,q种不符合最后可能被攑֤到数倍。越q得到反馈,问题可能p大?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>软g开发中一个很重要的概忉|“可行性”和“合理性”,无论我们做需求,设计q是开发,集成Q测试,都会遇到q两个问题。有些事情的可行性和合理性是我们可以通过事前的分析进行判断的Q但是有些问题就必须有一定的实践作ؓ基础。这也是一个反馈的问题。譬如说在某目中技术架构师军_采取一个技术架构,但是l过一些阶D늚开发发现它有一些技术上问题不能实现用户的关键需求,q时候就必须攑ּ它?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><B style="mso-bidi-font-weight: normal"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">“反馈”意味着两个意思,对一件事情的调查和根据调查做出决{?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在意识到反馈的重要性之后,你会要求所有的人都对P代的成果做出反馈。可能存在的问题是,是不是所有的人都意识C反馈的重要性ƈ且认真地d了呢Q如果客戯Z们只需要对q代出来的品“看看而已”,那么你就很难了解他们一些深层次的想法。再比如一ơP代中某些模块开发的q度比较慢,开发h员可能会抱怨技术方案不能满求,而实际的原因可能是设计不合理或者根本就是有人没有认真工作?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>中国国家队前Ll米卢曾l说q“态度军_一切”,反馈作ؓq代开发中臛_重要的一个方面,必须得到_的重视?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>获得反馈的方式和对于反馈信息的分析是另外一个重要的斚w。一般来ԌҎ软g开发角色的不同Q我们非常关注的是两cMh的反馈:目l之外的客户和项目组之内的各U实施h员?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>软g目一般都会要求客h安排专门的业务h员进行配合,在P代开发中Q这U配合不只是q行需求的整理和发掘,q包括对已经完成软g版本的评。在q个q程中应该有需求分析师的配合?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在每ơP代完成之后,软g目l应该有一些ȝ和分析活动。通过q些ȝ和分析,扑ֈ做得好和做得不好的方面?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>在非q代式的开发中Q也有反馈的环节。比如通常在Y件交付阶D会有一个试用期让用h出意见。而Y件团队在各种开发中都会有一些ȝzd。P代式开发的独特之处在于量早地引入反馈机制Q得反馈机制更加制度化Qƈ且,更加快速和灉|地分析这些反馈,把得到的l论应用C一阶段的开发中厅R?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>对于一些机制引L问题Q比如组l结构不合理Q角色分配不明确之类。最好有一个明的问题记录表。在每次q代完成以后这些问题记录下来,同时在下ơP代中努力改善它。如果相同的问题q箋出现在几ơP代中Q可能就说明目理Z问题?/FONT></SPAN></P> <H2 style="MARGIN: 7pt 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial"><FONT size=3>合作</FONT></SPAN></H2> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>软g团队中的合作是h们一直都在提倡的。我们在q里提到“合作”的意思ƈ不只包含团队内部的协作,q包括和客户的合作?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>q代开发需要快速反应,q需要各U不通角色h员的配合。如果h们做事情L拖拖拉拉Q就会g~Y仉目的q度。而且每个人对自己在P代中应该做什么事情必d清楚Q这需要事前的准备和角色的合理分配?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>q代需要用L配合Q实际上最好能够有客户?B style="mso-bidi-font-weight: normal">真正的系l用?/B>参加到P代过E中来,因ؓ他们是最有发a权的。很多项目中会让目l理或是pȝ分析师担当客户代表的角色Q这样做有很多弊病。有时出于各U原因客L实不能到现场配合的,我们也可以通过其他的途径获得客户反馈。比如一个阶DP代完成以后,可以把相x作用截屏加文字说明的方式发给客户Q让他们对品有一个直观的印象?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Z让团队能够有效快速地配合Q应该尽可能使用各种自动化工?/SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。比如自动化试理工具Q以及配|管理,集成以及发布之类的工兗通过对这些工L有效应用Q得各个成员能够快速获得信息?/SPAN></FONT></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>q代开发要拥抱变化Q主动适应变化。要让每个参与者都认识到这一点:不能够固步自,或者满于现有的成,不去思考可改进的地斏V从理者的角度上,必须重视每一个反馈信息?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>q代开发追求对d的度量。很多组l会把这U度量和员工的W效考评联系h。这U做法可能是合适的Q但是如果只是简单衡量工作量或者工作完成速度和质量,有可能会比较片面。毕竟Y件开发是一个环环相扣的q程Q表面上来看q个环节处理不好Q实际上可能是准备工作做得不好,或者其他h的配合不好?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所以如果在q代q程中出C问题Q一定要客观地分析,特别是应该挖掘导致这些问题出现的深层ơ原因。譬如在一ơP代中试人员发现了一?/SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q但是两ơP代过MQ这?/SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">仍然存在Q这p明对</SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的处理不够迅速(当然如果因ؓ某些原因q些事情被故意推q了的情况不)。这时就必须分析一下到底是什么原因造成了信息的不通畅。而不能简单地批评相关责Q人?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P> <H1 style="MARGIN: 11pt 0cm"><FONT size=3><FONT style="BACKGROUND-COLOR: #e5e5e5"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">ȝ</SPAN><SPAN lang=EN-US style="mso-fareast-font-family: 宋体"><o:p></o:p></SPAN></FONT></FONT></H1> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>本文对P代开发的五个关键Q变化,周期Q目标,反馈Q合作)斚wq行了讨论。作ZU方法论QP代开发的好处在于它软g团队变得更加灉|。在实施q代开发的q程中,应注意不能流于Ş式化Q切实做好每个环节的工作Q这h能获得满意的l果?/FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN lang=EN-US><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN lang=EN-US><FONT size=2>Email:jayliu@mail.csdn.net</FONT></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN lang=EN-US><A href="http://www.tkk7.com/jayliu"><FONT size=2>http://www.tkk7.com/jayliu</FONT></A><o:p></o:p></SPAN></P><img src ="http://www.tkk7.com/jayliu/aggbug/4283.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-14 10:08 <a href="http://www.tkk7.com/jayliu/archive/2005/05/14/4283.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google Toolbar的翻译功?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/14/4278.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Sat, 14 May 2005 00:52:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/14/4278.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4278.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/14/4278.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4278.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4278.html</trackback:ping><description><![CDATA[<P>前两天浏览网|偶然地把鼠标在一个字上面放了一会,l果居然被翻译了出来。仔l一看,发现不是金山词霸的原因。还一直以为是ie附加了翻译功能。结果今天偶然地隐藏了google ToolbarQ发现翻译功能不能用了。这才恍然大悟?BR><BR></P><IMG src="http://img64.photo.163.com/jayliu2000/8673209/186638867.jpg"><img src ="http://www.tkk7.com/jayliu/aggbug/4278.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-14 08:52 <a href="http://www.tkk7.com/jayliu/archive/2005/05/14/4278.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ejb3.0的几Ҏ著特?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/12/4241.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Thu, 12 May 2005 13:38:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/12/4241.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4241.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/12/4241.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4241.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4241.html</trackback:ping><description><![CDATA[<P class=MsoList style="MARGIN: 0cm 0cm 11pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 75.0pt"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman"><FONT size=2>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">          </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>元数据的引入Q以注释的Ş式表C元数据Q取代了q去大量的配|文?/FONT></SPAN></P> <P class=MsoList style="MARGIN: 0cm 0cm 11pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 75.0pt"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman"><FONT size=2>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">          </SPAN></FONT></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">各种</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">enterprise bean</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的定义都只需要定义一?/SPAN><SPAN lang=EN-US><FONT face="Times New Roman">POJO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US><FONT face="Times New Roman">POJI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配合元数据即可完?/SPAN></FONT></P> <P class=MsoList style="MARGIN: 0cm 0cm 11pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 75.0pt"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman"><FONT size=2>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">          </SPAN></FONT></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">回调机制Q?/SPAN><SPAN lang=EN-US><FONT face="Times New Roman">callback</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q也是用普通的Ҏ加以一定的注释Q代替了原有?/SPAN><SPAN lang=EN-US><FONT face="Times New Roman">ejbCreate</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之类的方?/SPAN></FONT></P> <P class=MsoList style="MARGIN: 0cm 0cm 11pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 75.0pt"><FONT face="Times New Roman"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT size=2>4.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">          </SPAN></SPAN></SPAN><SPAN lang=EN-US><FONT size=2>AOP</FONT></SPAN></FONT><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>概念的引入:允许在类定义中和其他cMҎ法进行拦?/FONT></SPAN></P> <P class=MsoList style="MARGIN: 0cm 0cm 11pt 75pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 75.0pt"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman"><FONT size=2>5.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">          </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=2>依赖注入Q允讔R过d特定注释向属性注入所依赖的对?BR><BR>ȝ来说Qejb3.0相对于ejb2.0来说实现更加单了Q甚x认ؓ比目前的一些轻量解决ҎQ比如spring framework之类Q还要简单?/FONT></SPAN></P><img src ="http://www.tkk7.com/jayliu/aggbug/4241.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-12 21:38 <a href="http://www.tkk7.com/jayliu/archive/2005/05/12/4241.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>J2SE5.0新特性示?--循环语句的增?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/12/4202.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Thu, 12 May 2005 02:57:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/12/4202.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4202.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/12/4202.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4202.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4202.html</trackback:ping><description><![CDATA[<H1 style="MARGIN: 11pt 0cm"><SPAN style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial"><FONT style="BACKGROUND-COLOR: #e5e5e5" size=3>循环语句的增?/FONT></SPAN></H1><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">之前cMq样的语句:</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>void cancelAll(Collection c) { <o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>for (Iterator i = c.iterator(); i.hasNext(); ) {<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">        </SPAN>TimerTask tt = (TimerTask) i.next();<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">        </SPAN>tt.cancel();<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>}<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'">}</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P></TD></TR></TBODY></TABLE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">以后可以q样写:</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></P> <P class=MsoBodyText style="MARGIN: 0cm 0cm 11pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>void cancelAll(Collection c) {<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>for (Object o : c)<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">   </SPAN><SPAN style="mso-spacerun: yes">     </SPAN>((TimerTask)o).cancel();<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>}<o:p></o:p></FONT></SPAN></P></TD></TR></TBODY></TABLE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT color=#000000><span id="asaq2qq" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">有时候我们可能写L代码Q?/SPAN></SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>List suits = ...;<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>List ranks = ...;<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>List sortedDeck = new ArrayList();<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>for (Iterator i = suits.iterator(); i.hasNext(); )<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>for (Iterator j = ranks.iterator(); j.hasNext(); )<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">        </SPAN>sortedDeck.add(new Card(i.next(), j.next()));<o:p></o:p></FONT></SPAN></P></TD></TR></TBODY></TABLE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span id="48my4e4" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN lang=EN-US><o:p><FONT face="Courier New" color=#0000ff> </FONT></o:p></SPAN></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT color=#000000><span id="sm4ay4m" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">q段代码不会按照我们设想的那么工作,因ؓ每次W二?/SPAN><SPAN lang=EN-US><FONT face="Courier New">for</FONT></SPAN></SPAN><span id="quu488a" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">语句的执行都会引?/SPAN><SPAN lang=EN-US><FONT face="Courier New">i.next()</FONT></SPAN></SPAN><span id="quc2o8e" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">的执行,实际上我们没有达到对</SPAN><SPAN lang=EN-US><FONT face="Courier New">i</FONT></SPAN></SPAN><span id="6iqy4qw" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">q行遍历的目的,而且可能会引起一?/SPAN><SPAN lang=EN-US><FONT face="Courier New">NoSuchElementException</FONT></SPAN></SPAN><span id="kkkgq2o" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">异常?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT color=#000000><span id="4eu4qsy" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">解决的一个办法是改写成如下代码:</SPAN></SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>for (Iterator i = suits.iterator(); i.hasNext(); ) {<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>Suit suit = (Suit) i.next();<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>for (Iterator j = ranks.iterator(); j.hasNext(); )<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">        </SPAN>sortedDeck.add(new Card(suit, j.next()));<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'">}</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P></TD></TR></TBODY></TABLE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><span id="cuuemgo" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN lang=EN-US><o:p><FONT face="Courier New" color=#0000ff> </FONT></o:p></SPAN></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT color=#000000><span id="so48ege" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">利用</SPAN><SPAN lang=EN-US><FONT face="Courier New">java</FONT></SPAN></SPAN><span id="qemmss2" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">语言的新Ҏ,我们可以q样写:</SPAN></SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>for (Suit suit : suits)<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">    </SPAN>for (Rank rank : ranks)<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2><SPAN style="mso-spacerun: yes">        </SPAN>sortedDeck.add(new Card(suit, rank));<o:p></o:p></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p><FONT size=2> </FONT></o:p></SPAN></P></TD></TR></TBODY></TABLE></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span id="eq44gqg" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><SPAN lang=EN-US><o:p><FONT face="Courier New" color=#0000ff> </FONT></o:p></SPAN></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><span id="aog2sys" class=CharCharCharCharCharCharCharCharCharCharCharCharCharCharCharChar><FONT color=#000000><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">q段代码是不是很漂亮Q?/SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"></SPAN></FONT></P><img src ="http://www.tkk7.com/jayliu/aggbug/4202.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-12 10:57 <a href="http://www.tkk7.com/jayliu/archive/2005/05/12/4202.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>J2SE5.0新特性示?--枚Dhttp://www.tkk7.com/jayliu/archive/2005/05/12/4206.htmlq?/dc:creator>q?/author>Thu, 12 May 2005 02:57:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/12/4206.htmlhttp://www.tkk7.com/jayliu/comments/4206.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/12/4206.html#Feedback0http://www.tkk7.com/jayliu/comments/commentRss/4206.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/4206.html枚D

在过去,我们必须用整型常C替枚举,随着J2SE 5.0的发布,q样的方法终于一M复返了?/SPAN>

一个简单的枚Dcd定义如下Q?/SPAN>

public enum Weather

{

       SUNNY,RAINY,CLOUDY

}

 

枚D可以用在switch语句中:

Weather weather=Weather.CLOUDY;

switch(weather)

{

       case SUNNY:

              System.out.println("It's sunny");

              break;

       case CLOUDY:

              System.out.println("It's cloudy");

              break;

       case RAINY:

              System.out.println("It's rainy");

              break;

}

 

枚Dcd可以有自q构造方法,不过必须是私有的Q也可以有其他方法的定义Q如下面的代码:

public enum Weather {

    SUNNY("It is sunny"),

    RAINY("It is rainy"),

    CLOUDY("It is cloudy");

 

    private String description;

 

    private Weather(String description) {

       this.description=description;

    }

   

    public String description() {

       return this.description;

    }

}

 

下面一D代码是对这个枚丄一个用:

for(Weather w:Weather.values())

{

    System.out.printf(                                                  "Description of %s is \"%s\".\n",w,w.description());

}

 

Weather weather=Weather.SUNNY;

System.out.println(weather.description() + " today");

 

如果我们有一个枚丄型,表示四则q算Q我们希望在其中定义一个方法,针对不同的值做不同的运,那么我们可以q样定义Q?/SPAN>

public enum Operation {

     PLUS, MINUS, TIMES, DIVIDE;

 

        // Do arithmetic op represented by this constant

        double eval(double x, double y){

            switch(this) {

                case PLUS:   return x + y;

                case MINUS:  return x - y;

                case TIMES:  return x * y;

                case DIVIDE: return x / y;

            }

            throw new AssertionError("Unknown op: " + this);

        }

}

 

q样写的问题是你如果没有最后一行抛出异常的语句Q编译就无法通过。而且如果我们惌d一个新的运,必L刻记着要在eval中添加对应的操作Q万一忘记的话׃抛出异常?/SPAN>

J2SE 5.0提供了解册个问题的办法Q就是你可以?/SPAN>eval函数声明?/SPAN>abstractQ然后ؓ每个值写不同的实玎ͼ如下所C:

 

public enum Operation {

     PLUS   { double eval(double x, double y) { return x + y; } },

     MINUS  { double eval(double x, double y) { return x - y; } },

     TIMES  { double eval(double x, double y) { return x * y; } },

     DIVIDE { double eval(double x, double y) { return x / y; } };

 

     abstract double eval(double x, double y);

}

 

q样避免了上面所说的两个问题Q不q代码量增加了一些,但是随着今后各种Java开?/SPAN> IDE的改q,代码量的问题应该会被淡化?/SPAN>



]]>
J2SE5.0新特性示?--原生cd的autoboxing和auto-unboxinghttp://www.tkk7.com/jayliu/archive/2005/05/12/4205.htmlq?/dc:creator>q?/author>Thu, 12 May 2005 02:57:00 GMThttp://www.tkk7.com/jayliu/archive/2005/05/12/4205.htmlhttp://www.tkk7.com/jayliu/comments/4205.htmlhttp://www.tkk7.com/jayliu/archive/2005/05/12/4205.html#Feedback1http://www.tkk7.com/jayliu/comments/commentRss/4205.htmlhttp://www.tkk7.com/jayliu/services/trackbacks/4205.html 

原生cd?/SPAN>autoboxing?/SPAN>auto-unboxing

我们知道Q在Java中,int,long{原生类型不是一个承自Object的类Q所以相应的Q有很多操作我们都不能利用原生类型操作,比如惌把一个整数放入到一个集合中Q我们必首先创Z?/SPAN>Integer对象Q然后再这个对象放入到集合中。当我们从集合中取数的时候,取出来的是一?/SPAN>Integer对象Q因此不能直接对它用加减乘除等q算W,而是必须?/SPAN>Integer.intValue()取到相应的值才可以Q这Lq程UC?/SPAN>boxing?/SPAN>unboxing?/SPAN>

J2SE5.0支持autoboxing?/SPAN>auto-unboxingQ也是说我们以后不需要再手动地做q些boxing?/SPAN>unboxing操作了,java语言会替我们完成。具体可以参照下面的CZQ?/SPAN>

List<Integer> intList=new ArrayList<Integer>();

intList.add(2);

intList.add(new Integer(5));

int i=3+intList.get(0);//i=5

int j=3+intList.get(1); //j=8

 

从这一D늨序中我们可以看到Q?/SPAN>autoboxing?/SPAN>auto-unboxing为我们省掉了很多不必要的工作?/SPAN>



]]>
J2SE5.0新特性示?--静态引?/title><link>http://www.tkk7.com/jayliu/archive/2005/05/12/4207.html</link><dc:creator>q?/dc:creator><author>q?/author><pubDate>Thu, 12 May 2005 02:56:00 GMT</pubDate><guid>http://www.tkk7.com/jayliu/archive/2005/05/12/4207.html</guid><wfw:comment>http://www.tkk7.com/jayliu/comments/4207.html</wfw:comment><comments>http://www.tkk7.com/jayliu/archive/2005/05/12/4207.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jayliu/comments/commentRss/4207.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jayliu/services/trackbacks/4207.html</trackback:ping><description><![CDATA[<H1 style="MARGIN: 11pt 0cm"><FONT size=3><FONT style="BACKGROUND-COLOR: #e5e5e5"><SPAN style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">静态引入(</SPAN><SPAN lang=EN-US><FONT face=Arial>static import</FONT></SPAN><SPAN style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">Q?/SPAN><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></FONT></H1> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">在过L们要使用其他包中某类的静态变量,一般都要在前面加上对应的类名:</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=2><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'">double r = Math.cos(Math.PI * theta);</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P></TD></TR></TBODY></TABLE> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">使用静态引入,我们可以把前面的cdLQ静态引入的语句是这LQ?/SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>import static java.lang.Math.PI;<o:p></o:p></FONT></SPAN></P></TD></TR></TBODY></TABLE> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">必须注意到这里最后不是到c?/SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'">Math,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">而是直接C定义的变?/SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'">PI</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">?/SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">静态引入不只对静态变量,也可以针寚w态方法。此外还可以使用</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'">*</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">Q如下面所C:</SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p></o:p></SPAN></FONT></P> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: silver; MARGIN: auto auto auto 59.4pt; BORDER-LEFT: medium none; WIDTH: 378pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 width=504 border=1> <TBODY> <TR style="mso-yfti-irow: 0; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 378pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=504> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: blue; FONT-FAMILY: 'Courier New'"><FONT size=2>import static java.lang.Math.*;<o:p></o:p></FONT></SPAN></P></TD></TR></TBODY></TABLE> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'"><o:p><FONT size=2> </FONT></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 54pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'; mso-bidi-language: AR-SA"><FONT size=2>除非我们Ҏ个静态常量(或者方法)讉K频度很大Q否则应该尽量避免用静态引入?/FONT></SPAN><SPAN lang=EN-US style="FONT-FAMILY: 'Courier New'; mso-bidi-language: AR-SA"><o:p></o:p></SPAN></P><img src ="http://www.tkk7.com/jayliu/aggbug/4207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jayliu/" target="_blank">q?/a> 2005-05-12 10:56 <a href="http://www.tkk7.com/jayliu/archive/2005/05/12/4207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://t66p.com" target="_blank">91ƷѸ</a>| <a href="http://97chaopeng2.com" target="_blank">þѹƷ</a>| <a href="http://tjtangpu.com" target="_blank">պëƬѹۿ</a>| <a href="http://bjgelinhotel.com" target="_blank">ĻƵ </a>| <a href="http://yy6767.com" target="_blank">պþëƬ</a>| <a href="http://wwby66636.com" target="_blank">ѻɫƵ</a>| <a href="http://yimintech.com" target="_blank">þþƷ</a>| <a href="http://aaa99999.com" target="_blank">ëƬAëƬѲ</a>| <a href="http://ninidian.com" target="_blank">ѹۺƵ߿ </a>| <a href="http://ynyinglie.com" target="_blank">avۺר</a>| <a href="http://mm9d.com" target="_blank">޹ƷþþžŴƬ</a>| <a href="http://zhaoav7.com" target="_blank">ȫһһëƬѿ</a>| <a href="http://ziguang1688.com" target="_blank">պƵ߹ۿ</a>| <a href="http://www-774220.com" target="_blank">99߾Ʒȫmy</a>| <a href="http://baoyutv777.com" target="_blank">ƷƵվ</a>| <a href="http://121fj.com" target="_blank">ղһ</a>| <a href="http://zzz134.com" target="_blank">ۺ</a>| <a href="http://szqsnt.com" target="_blank">Ʒһ</a>| <a href="http://wuaiav.com" target="_blank">߹ۿƵ</a>| <a href="http://ynkmht.com" target="_blank">ĻӰѹۿ</a>| <a href="http://szicon.com" target="_blank">޾Ʒ뼤AV</a>| <a href="http://714747.com" target="_blank">޺ݺady޾Ʒ</a>| <a href="http://gzbaida.com" target="_blank">AV㽶һ</a>| <a href="http://714747.com" target="_blank">GOGOGOѿ</a>| <a href="http://0453wcbyy.com" target="_blank">޹Ʒѹۿ</a>| <a href="http://www09191z.com" target="_blank">jlzzjlzz߲</a>| <a href="http://6132423.com" target="_blank">˳ɵӰ߲</a>| <a href="http://xcdys.com" target="_blank">һëƬѲ</a>| <a href="http://tv695.com" target="_blank">Ƶ߹ۿ</a>| <a href="http://bdgxhome.com" target="_blank">ɫַ</a>| <a href="http://iciap.com" target="_blank">avƷר߹ۿ</a>| <a href="http://xcdys.com" target="_blank">ݺݺݰƵ</a>| <a href="http://18736374.com" target="_blank">պѸƵ</a>| <a href="http://miya77772.com" target="_blank">޾Ʒ鶼</a>| <a href="http://liuxilife.com" target="_blank">ɫ˵</a>| <a href="http://cdessc.com" target="_blank">Ļѹۿ</a>| <a href="http://cao9999.com" target="_blank">պӰ</a>| <a href="http://fdhkauto.com" target="_blank">þþþþ޾Ʒ</a>| <a href="http://fcw70.com" target="_blank">ҹӰȫѿ</a>| <a href="http://23usxx.com" target="_blank">㽶97ѹ</a>| <a href="http://lanoss.com" target="_blank">ҹAVƬ</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>