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

📄 j-javalibrary-2-4.shtml

📁 构造java库
💻 SHTML
字号:
<html><!--This panel generated from the developerWorks XML tag set for tutorials, Version 1.8.9.  (C) Copyright 2000 IBM Corporation.  All rights reserved.--><head><title>Introduction to libraries</title><style type="text/css"><!--      body                 { color: #000000; background-color: #ffffff; }       dt                   { font-weight: bold; }       code                 { font-family: Courier, monospace; font-size: +2; }      titleCode            { font-family: Courier, monospace; font-size: +4; }      ol.alpha             { list-style-type: upper-alpha; }      span.center          { text-align: center; }      span.right           { text-align: right; }      span.constant        { color: #990099; }      span.keyword         { color: #993333; }      span.function-name   { color: #666633; }      span.comment         { color: #666666; }      span.string          { color: #0000ff; }      span.variable-name   { color: #000066; }      span.type            { color: #006600; }      span.spacer          { font-size: 1pt; }    --></style><meta http-equiv="content-Type" content="text/html; charset=gb2312"></head><body bgcolor="ffffff"><script language="javascript"><!--var emailAbstract="This tutorial reviews how the Java language can help you make a good, reusable library.  It covers the key principles of good library design and the most efficient ways to implement each of these ideas in the Java language.";var justTitle="Build your own Java library";var tutorialPrereqs="http://www-4.ibm.com/software/developer/education/r-jlib.shtml";var menu1blurb="Tutorial tips"; var menu2blurb="Introduction to libraries"; var menu3blurb="Design issue: Encapsulation"; var menu4blurb="Design issue: Extensibility"; var menu5blurb="Design issue: Debugging information"; var menu6blurb="The source code"; var menu7blurb="Wrapup";       var browser = "x";      if (navigator.userAgent.indexOf("Mozilla/4") != -1) browser = "N3";      else if (navigator.userAgent.indexOf("Mozilla/3") != -1) browser = "N3";      else browser = "x";            if (browser=="N3")      {    var menu1over=new Image(108,68); var menu1out=new Image(108,68); var menu2over=new Image(108,68); var menu2out=new Image(108,68); var menu3over=new Image(108,68); var menu3out=new Image(108,68); var menu4over=new Image(108,68); var menu4out=new Image(108,68); var menu5over=new Image(108,68); var menu5out=new Image(108,68); var menu6over=new Image(108,68); var menu6out=new Image(108,68); var menu7over=new Image(108,68); var menu7out=new Image(108,68);         var topmainover=new Image(77,15);        var topmainout=new Image(77,15);        var bottommainover=new Image(77,15);        var bottommainout=new Image(77,15);        var topsectionover=new Image(98,15);        var topsectionout=new Image(98,15);        var bottomsectionover=new Image(98,15);        var bottomsectionout=new Image(98,15);        var topfeedbackover=new Image(80,15);        var topfeedbackout=new Image(80,15);        var bottomfeedbackover=new Image(80,15);        var bottomfeedbackout=new Image(80,15);        var toppreviousover=new Image(77,15);        var toppreviousout=new Image(77,15);        var bottompreviousover=new Image(77,15);        var bottompreviousout=new Image(77,15);        var topnextover=new Image(60,15);        var topnextout=new Image(60,15);        var bottomnextover=new Image(60,15);        var bottomnextout=new Image(60,15);        var topnextsectionover=new Image(108,15);        var topnextsectionout=new Image(108,15);        var bottomnextsectionover=new Image(108,15);        var bottomnextsectionout=new Image(108,15);          menu1over.src="imagemaster/himenu1.jpg"; menu1out.src="imagemaster/menu1.jpg"; menu2over.src="imagemaster/himenu2.jpg"; menu2out.src="imagemaster/menu2.jpg"; menu3over.src="imagemaster/himenu3.jpg"; menu3out.src="imagemaster/menu3.jpg"; menu4over.src="imagemaster/himenu4.jpg"; menu4out.src="imagemaster/menu4.jpg"; menu5over.src="imagemaster/himenu5.jpg"; menu5out.src="imagemaster/menu5.jpg"; menu6over.src="imagemaster/himenu6.jpg"; menu6out.src="imagemaster/menu6.jpg"; menu7over.src="imagemaster/himenu7.jpg"; menu7out.src="imagemaster/menu7.jpg";         var mainblurb="Main menu";        var sectionblurb="Section menu";        var feedbackblurb="Give feedback on this tutorial";        var previousblurb="Go to previous panel";        var nextblurb="Go to next panel";        var nextsectionblurb="Go to next section";        topmainover.src="../i/h-main.gif";        topmainout.src="../i/main.gif";        bottommainover.src="../i/h-main.gif";        bottommainout.src="../i/main.gif";        topsectionover.src="../i/h-section.gif";        topsectionout.src="../i/section.gif";              bottomsectionover.src="../i/h-section.gif";        bottomsectionout.src="../i/section.gif";              topfeedbackover.src="../i/h-feedback.gif";        topfeedbackout.src="../i/feedback.gif";        bottomfeedbackover.src="../i/h-feedback.gif";        bottomfeedbackout.src="../i/feedback.gif";        toppreviousover.src="../i/h-previous.gif";        toppreviousout.src="../i/previous.gif";        bottompreviousover.src="../i/h-previous.gif";        bottompreviousout.src="../i/previous.gif";        topnextover.src="../i/h-next.gif";        topnextout.src="../i/next.gif";        bottomnextover.src="../i/h-next.gif";        bottomnextout.src="../i/next.gif";        topnextsectionout.src="../i/nextsection.gif";        topnextsectionover.src="../i/h-nextsection.gif";        bottomnextsectionout.src="../i/nextsection.gif";        bottomnextsectionover.src="../i/h-nextsection.gif";      }      function iOut(image)      {        if (browser=="N3")document[image].src=eval(image + "out.src");      }      function iOver(image)      {        if (browser=="N3")document[image].src=eval(image + "over.src");      }     // --></script><a href="#navskip"><img border="0" alt="Skip to main content" src="../i/c.gif"></a><!--#include virtual="/developerWorks/inc/tuto-inc/tuto-header.inc" --><!--#include virtual="/developerWorks/inc/tuto-inc/tuto-java-header.inc" --><br x="7"><img src="imagemaster/masthead.jpg" alt="Build your own Java library"></td><td width="*" valign="bottom" align="right"><a border="0" href="../j-library.zip"><img alt="下载教程 zip 文件" border="0" src="../i/icon-zip.gif"></a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td height="2" colspan="2"><img height="2" width="1" src="../i/c.gif"></td></tr></table><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD width="150" height="1" bgcolor="#000000" colspan="6"><IMG alt="" height="1" width="150" src="../i/c.gif"></TD></TR><TR><TD background="../i/sw-gold.gif"><a border="0" href="index.shtml" onMouseOver="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;" onMouseOut="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"><img alt="Main menu" border="0" src="../i/main.gif" name="topmain"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;" onMouseOut="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;" href="index2.shtml"><img alt="Section menu" border="0" src="../i/section.gif" name="topsection"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;" onMouseOut="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;" href="j-javalibrary-7-3.shtml"><img alt="Give feedback on this tutorial" border="0" src="../i/feedback.gif" name="topfeedback"></a></TD><TD width="100%" background="../i/sw-gold.gif"><img src="../i/c.gif"></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topprevious'); iOver('bottomprevious'); self.status=previousblurb; return true;" onMouseOut="iOut('topprevious'); iOut('bottomprevious'); self.status=''; return true;" href="j-javalibrary-2-3.shtml"><img alt="Previous" border="0" src="../i/previous.gif" name="topprevious"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onMouseOut="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="j-javalibrary-2-5.shtml"><img alt="Next" border="0" src="../i/next.gif" name="topnext"></a></TD></TR></TABLE><table bgcolor="ffffff" cellspacing="0" cellpadding="2" border="0" height="400" width="100%"><tr valign="bottom"><a name="navskip"></a><td height="25" colspan="4"><img border="0" height="25" width="562" src="imagemaster/titlebar2.jpg" alt="2. Introduction to libraries"></td></tr><tr><td bgcolor="ffffff" width="15">&nbsp;</td><td bgcolor="ffffff" width="12">&nbsp;</td><td valign="top" align="left" bgcolor="ffffff" width="*"><p><br x="7"><table cellspacing="0" cellpadding="0" border="0"><tr><td width="90%"><font size="4" face="Verdana, Arial, Helvetica"><b>Put yourself in the user's shoes</b></font></td><td width="200" align="right"><font size="1" face="Verdana, Arial, Helvetica"><nobr>    page 4 of 6</nobr></font></td></tr></table><br x="7"><br x="7"></p><font size="2" face="Verdana, Arial, Helvetica"><p>

When designing a library, it's important to put yourself in the place of the person who is going to be using the library.  Ask these questions:

</p><p>

<ul><li>What problem will the library solve? (For example, what should the end result be?)
</li><li>What details do the users care about? (For example, how do they want to get to the end results?)
</li><li>What details would the users rather forget about? (For example, what elements and operations do they want other parts of the program to handle?)
</li></ul>

</p><p>

In the final analysis, good library design involves a bit of
psychology.  Sure, your code works well, but does it <i>seem</i>
like it works well?  When people hear or read about it, will they say
to themselves, "Wow, that's exactly what I need and exactly how I would have done it myself!"

        </p><br x="7"></font></td></tr></table><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD background="../i/sw-gold.gif"><a border="0" href="index.shtml" onMouseOver="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;" onMouseOut="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"><img alt="Main menu" border="0" src="../i/main.gif" name="bottommain"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;" onMouseOut="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;" href="index2.shtml"><img alt="Section menu" border="0" src="../i/section.gif" name="bottomsection"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;" onMouseOut="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;" href="j-javalibrary-7-3.shtml"><img alt="Give feedback on this tutorial" border="0" src="../i/feedback.gif" name="bottomfeedback"></a></TD><TD width="100%" background="../i/sw-gold.gif"><img src="../i/c.gif"></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topprevious'); iOver('bottomprevious'); self.status=previousblurb; return true;" onMouseOut="iOut('topprevious'); iOut('bottomprevious'); self.status=''; return true;" href="j-javalibrary-2-3.shtml"><img alt="Previous" border="0" src="../i/previous.gif" name="bottomprevious"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onMouseOut="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="j-javalibrary-2-5.shtml"><img alt="Next" border="0" src="../i/next.gif" name="bottomnext"></a></TD></TR><TR><TD width="150" height="1" bgcolor="#000000" colspan="6"><IMG alt="" height="1" width="150" src="../i/c.gif"></TD></TR></TABLE><!--#include virtual="/developerWorks/inc/tuto-inc/tuto-footer.inc" --></body></html>

⌨️ 快捷键说明

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