📄 114690.htm
字号:
<html xmlns="http://www.w3.org/TR/xhtml1/strict"> <head> <title>天极网</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></meta> <meta http-equiv="Pragma" content="no-cache"></meta> <meta http-equiv="expires" content="Mon,12 May 1998 00:36:05 GMT"></meta> <link rel="stylesheet" href="/xslimages/css/cpcw.css"></link> </head> <style>.nava { font-size: 9pt}.font1{font-size: 10.5pt}</style> <body bgcolor="#FFFFFF" topmargin="2"><table width="760" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="20%" rowspan="3" valign="top" align="center"><table width="95%" border="1" cellspacing="0" cellpadding="0" height="60" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF"><tr valign="middle" align="center"><td><div align="center"><span class="nava">天极硬件,新闻及时<br>资料详尽,敬请关注<br><a href="/33554432/35651584/yingjian.htm">www.myhard.com</a></span></div></td></tr></table></td><td width="57%" valign="bottom" rowspan="3" align="center"><div align="center"><script language="JavaScript" src="http://ad.cpcw.com/js/school.js"></script></div></td><td width="20%" valign="top" rowspan="3" align="center"><table width="95%" border="1" cellspacing="0" cellpadding="0" height="60" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF"><tr valign="middle" align="center"><td><div align="center"><span class="nava">好又多电子商务<br>让您一点动心<br><a href="http://www.hoyodo.com">www.hoyodo.com</a></span></div></td></tr></table></td></tr><tr></tr><tr></tr></table><table width="760" border="0" cellspacing="0" cellpadding="0" height="70" align="center"><tr><td width="145" valign="bottom" rowspan="3"><img src="/xslimages/content/logo.gif" width="140" height="60"></img></td><td colspan="3" width="100%" height="33" align="center"><a href="/" target="_blank">首页</a>| <a href="/33554432/36700160/news.htm" target="_blank">新闻中心</a>| <a href="/33554432/50331648/business.htm" target="_blank">企业中心</a>| <a href="/33554432/41943040/caijing.htm" target="_blank">财经中心</a>| <a href="/33554432/39845888/fashion.htm" target="_blank">时尚中心</a>| <a href="/33554432/35651584/yingjian.htm" target="_blank">硬件中心</a>| <a href="/33554432/34603008/school.htm" target="_blank">学习中心</a>| <a href="/33554432/37748736/game.htm" target="_blank">游戏中心</a>| <a href="/33554432/38797312/ziyuan.htm" target="_blank">资源中心</a>| <a href="http://www.hoyodo.com/" target="_blank">社区</a>| <a href="http://training.yesky.com/" target="_blank">网校</a></td></tr><tr><td colspan="3" width="78%" height="20" align="right"><b>中心栏目:<a href="http://www.mydown.com" target="_blank"><font color="#FF0000"><u>红辣椒软件下载</u></font></a></b><a href="http://soft.yesky.com" target="_blank"> 软件之窗 </a><a href="http://desktop.yesky.com" target="_blank">天极桌面网 </a><a href="http://art.yesky.com" target="_blank">美工教室 </a><a href="http://itdreamer.yesky.com" target="_blank">程序方舟 </a><a href="http://homepage.yesky.com" target="_blank">网页陶吧 </a><a href="http://safe.yesky.com" target="_blank">安全之路</a><a href="http://soft.yesky.com" target="_blank"></a></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" width="760"><tbody><tr bgcolor="#333333"><td colspan="2" height="1"></td></tr><tr><td bgcolor="#ff9900" height="16" valign="bottom" width="72%"><font color="#000000"><b><font color="#ffffff">学 习 中 心</font></b></font></td><td bgcolor="#6699cc" height="16" width="28%"><div align="center"><font face="Arial, Helvetica, sans-serif"><b><font color="#ffffff">N E T S C H O O L</font></b></font></div></td></tr><tr bgcolor="#333333"><td colspan="2" height="1"></td></tr></tbody></table><table align="center" border="0" cellpadding="0" cellspacing="0" width="760" bgcolor="#eeeeee"><td colspan="2" height="28"><div align="center"><a href="/33554432/34603008/34635776/34636800/34636832/schoolinverse1.htm" target="_blank"><font color="#000000">HTML</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34636800/34636864/schoolinverse1.htm" target="_blank"><font color="#000000">JavaScript</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34636800/34636928/schoolinverse1.htm" target="_blank"><font color="#000000">CSS</font></a><font color="#000000"> _ <a href="/33554432/34603008/34635776/34637824/34637952/schoolinverse1.htm" target="_blank"><font color="#000000"> PHP </font></a><font color="#000000"> _ </font></font><a href="/33554432/34603008/34635776/34637824/34637888/schoolinverse1.htm" target="_blank"><font color="#000000">ASP</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34635776/34637824/34637920/schoolinverse1.htm" target="_blank"><font color="#000000">Perl</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34638848/34638880/schoolinverse1.htm" target="_blank"><font color="#000000">Dreamweaver</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34639872/34639904/schoolinverse1.htm" target="_blank"><font color="#000000">XML</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34734080/schoolinverse2.htm" target="_blank"><font color="#000000">病毒</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/67108864/68157440/68419584/inverse2.htm" target="_blank"><font color="#000000">程序开发</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34799616/34800640/schoolinverse1.htm" target="_blank"><font color="#000000">Email</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34897920/34898944/schoolinverse1.htm" target="_blank"><font color="#000000">Windows 9x</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34897920/34900992/schoolinverse1.htm" target="_blank"><font color="#000000">Linux</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34963456/34966528/schoolinverse1.htm" target="_blank"><font color="#000000">WPS</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34963456/34964480/schoolinverse1.htm" target="_blank"><font color="#000000">Word</font></a></div></td></table><table width="760" border="0" cellspacing="0" cellpadding="0" height="30" align="center"><tr><td align="left" valign="bottom"><span class="nava"><span class="nava"><a href="/index.htm">首页</a>→ <a href="/33554432/34603008/school.htm">学习中心</a>→ <a href="/33554432/34603008/34668544/schoolinverse2-pro.htm">程序方舟</a>→ <a href="/33554432/34603008/34668544/34672640/schoolinverse2.htm">技巧经验</a>→ <a href="/33554432/34603008/34668544/34672640/34672672/schoolinverse1.htm">DELPHI技巧</a>→ </span></span></td><td width="2%"></td></tr></table><table width="760" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td colspan="3" valign="top" width="75%"><table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000"><tr bgcolor="#FFFFFF"><td width="100%" colspan="4" align="left"><table width="95%" align="center"><tr><td class="font1"><p align="center"><br><font size="3">Delphi 中面向对象编程之我见</font><br><span class="nava"><font color="#CC9933">2000-09-16· 940801·delhpi技术网</font></span></p><p>本文出自<a href="http://www.delphiuser.com" target="_blank">delphi技术网</a> </p><p> 面向对象的编程技术提出来也有些年头了,开发大型软件的时候采用面向对象的编程技术可以缩短程序的开发周期,提高程序的可读性,易调试性,同时也就相应的提高了程序的可维护性,而对大型软件而言,可维护性是保证其生命力的一个极为重要的指标。<br> 不知大家注意到没有,可视化程度很高的编程语言在采用面向对象的编程技术上很难处理。例如 VB,4.0基本不支持面向对象的编程,5.0 好一些,但微软也只敢说在面向对象的编程上 5.0 比 4.0 好得多,而不敢说 5.0 支持完全的面向对象的编程(6.0 我没用过,不知道,如果能支持,也是 VB 爱好者的福音了)。这大概就是人们常说的不用 VB 做大型程序的重要原因之一吧。 我不知 Delphi 是从什么版本开始提供面向对象编程支持的,但我从 VB 5.0 转到 Delphi 4.0,除了项目要求外,这是最重要的原因了。<br> 由于 Delphi 除了支持面向对象的编程外,也支持一般的面向过程的编程,而且因为其可视化技术的运用,很多人(包括我)很容易就偏离了面向对象的方向,实际上,我觉得要实现面向对象的编程也不难,因为 Delphi 给你的全都是对象,你只要在编程的时候注意自己的代码就是了。下面是我对在 Delphi 中采用面向对象技术的一些体会:<br></p><p>1.不要用全局变量<br> 即使要用,也要用全局对象来代替它。习惯了面向过程编程的程序员在这点上很容易犯错,而且这一点相对来说也比较难掌握。实际上,全局变量也是面向过程编程技术的一个很大的缺陷,难跟踪,难调试,也就难维护。<br> 为什么要用对象而不是变量呢?对象可以封装对变量的操作,任何对该变量的操作都必须通过调用对象的方法来完成,我们可以在操作该变量的方法中设置断点来调试,这就解决了前面所提到的 3 个难点(难跟踪、难调试、难维护)。<br> 举个常见的例子(也许并不能最大限度的反映这个问题):让你做一个 IE,对于 Internet Option,你打算怎样处理?<br> 根据以上的讨论,我的想法是写一个 TDefaultINI 类,这个类负责 Option 中各项设置的保存,读取。Option window 和别的需要操作其中设置的对象都通过这个类来进行处理。这样就实现了数据的封装。你可以定义一个 TDefaultINI 类的实例作为全局对象,当然,因为这些设置是保存在存储器中可以随时读取的,你也可以只在需要的时候创建一个 Tdefault 对象来完成你的功能。<br></p><p>2.对象之间交换数据,尽可能的使用属性而不是变量<br> 为什么要用属性而不是变量呢?对数据的操作可以通过属性的方法进行封装,一旦以后对象内部的数据结构发生了变化,只要我们提供的属性接口不变,对程序别的部分的影响就能减小到最小。例如 Form 之间通过属性来交换数据。以后因为某个原因你得将原来用数组实现的东西改为用链表实现,只要你的属性接口仍然是数组,那对别的对象就几乎没有影响。<br></p><p>3.合理的安排对象的方法<br> 我直接举例来说明这个问题,例如在连接数据库的时候,你是在主 Form 中设置好 TdataModule 中 Tdatabase 的 AliasName 和 Params,然后用 DataModule.Database.Open 来连接呢,还是写一个 TdataModule.ConnectToDatabase
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -