夢幻之旅
DEBUG - 天道酬勤
::
首頁
::
新隨筆
::
聯(lián)系
::
聚合
::
管理
::
671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
<
2011年8月
>
日
一
二
三
四
五
六
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
公告
本博客中未注原創(chuàng)的文章均為轉(zhuǎn)載,對轉(zhuǎn)載內(nèi)容可能做了些修改和增加圖片注釋,如果侵犯了您的版權(quán),或沒有注明原作者,請諒解
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(21)
給我留言
查看公開留言
查看私人留言
隨筆分類
(644)
Android(10)
(rss)
ANT(4)
(rss)
C#(10)
(rss)
C/C++(16)
(rss)
CSS(3)
(rss)
DataBase(119)
(rss)
DB-DailyMmaintenance(16)
(rss)
Design Patterns(27)
(rss)
english
(rss)
Exceptions(7)
(rss)
EXT(39)
(rss)
FLASH(9)
(rss)
Hardware(20)
(rss)
Hibernate(13)
(rss)
Html(23)
(rss)
Java(143)
(rss)
java Net(10)
(rss)
JavaScript(39)
(rss)
Linux(26)
(rss)
php(5)
(rss)
Regular Exp(3)
(rss)
Spring(17)
(rss)
Struts(12)
(rss)
TOOL(43)
(rss)
VB/VBA/VBS(5)
(rss)
webservice(9)
(rss)
XML(2)
(rss)
我的夢幻旅途(14)
(rss)
隨筆檔案
(669)
2017年9月 (4)
2016年10月 (1)
2015年6月 (1)
2015年4月 (2)
2015年1月 (1)
2014年8月 (2)
2014年7月 (9)
2014年6月 (1)
2014年5月 (2)
2014年4月 (3)
2014年3月 (3)
2013年10月 (4)
2013年9月 (8)
2013年8月 (4)
2013年6月 (3)
2013年5月 (4)
2013年4月 (7)
2013年3月 (1)
2013年1月 (3)
2012年12月 (4)
2012年11月 (1)
2012年10月 (1)
2012年9月 (4)
2012年8月 (1)
2012年7月 (2)
2012年6月 (1)
2012年5月 (4)
2012年4月 (2)
2012年3月 (1)
2012年2月 (4)
2012年1月 (6)
2011年12月 (10)
2011年11月 (7)
2011年10月 (6)
2011年9月 (37)
2011年8月 (34)
2011年7月 (44)
2011年6月 (10)
2011年5月 (5)
2011年4月 (3)
2011年3月 (1)
2011年2月 (1)
2011年1月 (18)
2010年12月 (9)
2010年11月 (13)
2010年10月 (17)
2010年9月 (2)
2010年8月 (10)
2010年7月 (10)
2010年6月 (5)
2010年5月 (8)
2010年4月 (9)
2010年3月 (11)
2010年2月 (3)
2010年1月 (8)
2009年12月 (6)
2009年11月 (10)
2009年10月 (5)
2009年9月 (1)
2009年8月 (18)
2009年7月 (6)
2009年6月 (2)
2009年5月 (1)
2009年4月 (4)
2009年3月 (6)
2009年2月 (5)
2009年1月 (3)
2008年12月 (13)
2008年11月 (13)
2008年10月 (30)
2008年9月 (9)
2008年8月 (24)
2008年7月 (17)
2008年6月 (15)
2008年5月 (16)
2008年4月 (15)
2008年3月 (19)
2008年2月 (3)
2008年1月 (20)
2007年12月 (24)
2007年11月 (9)
文章檔案
(6)
2008年4月 (1)
2008年3月 (1)
2008年1月 (2)
2007年11月 (2)
最新隨筆
1.?PP代碼生成器(四) 使用解決方案生成代碼
2.? PP代碼生成器(三) 設(shè)計freemarker模板, 創(chuàng)建解決方案
3.? PP代碼生成器(二) 解決方案, 生成任務(wù), 輔助設(shè)計面板
4.? PP代碼生成器(一) 簡介, 下載, 運(yùn)行
5.?PP持久層代碼生成器
6.?比較好的博客
7.?系統(tǒng)集成項(xiàng)目管理工程師
8.?軟件公司項(xiàng)目經(jīng)理崗位職責(zé)
9.?聯(lián)想筆記本 顯示屏 鍵盤失靈 釋放靜電
10.?eclipse maven
積分與排名
積分 - 958986
排名 - 37
最新評論
1.?re: Myeclipse 快捷鍵大全(絕對全)
crl+向右箭頭(輸入法有問題打不出來)移到下一個參數(shù)的位置,然后crl+shift+向右箭頭 選中該位置的參數(shù)即可
--紅領(lǐng)巾
2.?re: Log4j基本使用方法
555
--555
3.?re: Myeclipse 快捷鍵大全(絕對全)[未登錄]
很不錯,謝謝
--銀狐
4.?re: Flex 表單
是誰這么無聊~嗚~~~
--HUIKK
5.?re: Spring AfterReturning 異常
具體是什么意思啊
--dingli
閱讀排行榜
1.?Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream(70028)
2.?log4j.properties 使用說明(42078)
3.?Myeclipse 快捷鍵大全(絕對全)(32724)
4.?TNSNAMES.ORA 配置(24392)
5.?oracle 樹狀查詢(21359)
評論排行榜
1.?Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream(53)
2.?JMail 異常: java.lang.NoClassDefFoundError: javax/activation/DataSource(21)
3.?javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first(14)
4.?java 讀取 excel 2003 或 excel 2007(14)
5.?java.lang.UnsupportedClassVersionError: Bad version number in .class file(8)
[原創(chuàng)]設(shè)計模型探索P-template method parttern之死模活樣
模板方法
定義一個操作算法的骨架,而將一些步驟沿遲到子類中去實(shí)現(xiàn),模板方法使了類可能不改變算法的結(jié)構(gòu)即可以重定義該算法的某一些特定步驟.
組成部份
1.抽象模板 是一個抽象類,包含一系列的算法和一個模板方法,模板方法需要加final來修飾.
2.具體模板 繼承自抽象類.
各組成部份之間的關(guān)系
適用場景:
設(shè)計者需要給出一個算法的固定步驟,并將某一些步驟的具體實(shí)現(xiàn)留給子類來實(shí)現(xiàn).
需要對代碼進(jìn)行重構(gòu),將各個子類的公共行為取出來放到一個共同的父親類中以避免代碼重復(fù)
例子:
1.抽象模板
package
template;
/** */
/**
* <ul>
* <li>Title:[AbstractTemplate]</li>
* <li>Description: [抽象模板]</li>
* <li>Copyright 2009 Upengs Co., Ltd.</li>
* <li>All right reserved.</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
@version
1.0
*/
public
abstract
class
DatabaseExecuteTemplate
{
/** */
/**
* <ul>
* <li>Description:[加載驅(qū)動]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
loadDrive();
/** */
/**
* <ul>
* <li>Description:[連接數(shù)據(jù)庫]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
connectDataBase();
/** */
/**
* <ul>
* <li>Description:[創(chuàng)建statement]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
createStatement();
/** */
/**
* <ul>
* <li>Description:[執(zhí)行sql]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
executeSQL(String sql);
/** */
/**
* <ul>
* <li>Description:[關(guān)閉statement]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
closeStatement();
/** */
/**
* <ul>
* <li>Description:[關(guān)閉連接]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*/
public
abstract
void
closeConnect();
/** */
/**
* <ul>
* <li>Description:[是否刷新勾子]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
@return
*/
public
abstract
boolean
isFresh();
/** */
/**
* <ul>
* <li>Description:[刷新]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
@return
*/
public
abstract
void
fresh();
/** */
/**
* <ul>
* <li>Description:[執(zhí)行sql]</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
@param
sql
*/
public
final
void
exceute(String sql)
{
//
加載驅(qū)動
this
.loadDrive();
//
連接數(shù)據(jù)庫
this
.connectDataBase();
//
創(chuàng)建statement
this
.createStatement();
//
執(zhí)行sql
this
.executeSQL(sql);
//
關(guān)閉statement
this
.closeStatement();
//
關(guān)系連接
this
.closeConnect();
//
使用勾子改變算法
if
(isFresh())
{
//
刷新操作
this
.fresh();
}
}
}
2.具體模板1
package
template;
/** */
/**
* <ul>
* <li>Title:[OracleExecuteTemple]</li>
* <li>Description: [oracle模板]</li>
* <li>Copyright 2009 Upengs Co., Ltd.</li>
* <li>All right reserved.</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
*
@version
1.0
*/
public
class
OracleExecuteTemple
extends
DatabaseExecuteTemplate
{
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#closeConnect()
*/
public
void
closeConnect()
{
//
TODO Auto-generated method stub
System.out.println(
"
oracle 關(guān)閉連接
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#closeStatement()
*/
public
void
closeStatement()
{
//
TODO Auto-generated method stub
System.out.println(
"
oracle 關(guān)閉statement
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#connectDataBase()
*/
public
void
connectDataBase()
{
//
TODO Auto-generated method stub
System.out.println(
"
oracle 連接數(shù)據(jù)庫
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#createStatement()
*/
public
void
createStatement()
{
//
TODO Auto-generated method stub
System.out.println(
"
oracle 創(chuàng)建statement
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#executeSQL()
*/
public
void
executeSQL(String sql)
{
//
TODO Auto-generated method stub
System.out.println(
"
oracle 執(zhí)行SQL:
"
+
sql);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#fresh()
*/
public
void
fresh()
{
System.out.println(
"
oracle 刷新
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#isFresh()
*/
public
boolean
isFresh()
{
return
false
;
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#loadDrive()
*/
public
void
loadDrive()
{
System.out.println(
"
oracle 加載驅(qū)動
"
);
}
}
3.具體模板2
package
template;
/** */
/**
* <ul>
* <li>Title:[DB2ExecuteTemple]</li>
* <li>Description: [DB2模板]</li>
* <li>Copyright 2009 Upengs Co., Ltd.</li>
* <li>All right reserved.</li>
* <li>Created by [Huyvanpull] [2011-8-2]</li>
* <li>Midified by [modifier] [modified time]</li>
* </ul>
*
*
@version
1.0
*/
public
class
DB2ExecuteTemple
extends
DatabaseExecuteTemplate
{
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#closeConnect()
*/
public
void
closeConnect()
{
//
TODO Auto-generated method stub
System.out.println(
"
DB2 關(guān)閉連接
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#closeStatement()
*/
public
void
closeStatement()
{
//
TODO Auto-generated method stub
System.out.println(
"
DB2 關(guān)閉statement
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#connectDataBase()
*/
public
void
connectDataBase()
{
//
TODO Auto-generated method stub
System.out.println(
"
DB2 連接數(shù)據(jù)庫
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#createStatement()
*/
public
void
createStatement()
{
//
TODO Auto-generated method stub
System.out.println(
"
DB2 創(chuàng)建statement
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#executeSQL()
*/
public
void
executeSQL(String sql)
{
//
TODO Auto-generated method stub
System.out.println(
"
DB2 執(zhí)行SQL:
"
+
sql);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#fresh()
*/
public
void
fresh()
{
System.out.println(
"
DB2 刷新
"
);
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#isFresh()
*/
public
boolean
isFresh()
{
return
true
;
}
/**/
/*
* (non-Javadoc)
*
* @see template.DatabaseExecuteTemplate#loadDrive()
*/
public
void
loadDrive()
{
System.out.println(
"
DB2 加載驅(qū)動
"
);
}
}
4.測試類
package
template;
public
class
Test
{
public
static
void
main(String[] args)
{
DatabaseExecuteTemplate db2
=
new
DB2ExecuteTemple();
db2.exceute(
"
select count(*) from users
"
);
OracleExecuteTemple oracle
=
new
OracleExecuteTemple();
oracle.exceute(
"
select count(*) from users
"
);
}
}
posted on 2011-08-02 17:28
HUIKK
閱讀(387)
評論(0)
編輯
收藏
所屬分類:
Design Patterns
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
[原創(chuàng)]設(shè)計模型探索S-GoF,設(shè)計模式的分類
[原創(chuàng)]設(shè)計模型探索R-mediator parttern之月下老人
[原創(chuàng)]設(shè)計模型探索Q-bridge parttern之橋歸橋路歸路
[原創(chuàng)]設(shè)計模型探索P-template method parttern之死模活樣
[原創(chuàng)]設(shè)計模型探索O2-proxy parttern之桃代李疆
[原創(chuàng)]設(shè)計模型探索O1-proxy parttern之桃代李疆
[原創(chuàng)]設(shè)計模型探索N -flyweight parttern之有福同享
[原創(chuàng)]設(shè)計模型探索M-state parttern之各有千秋
[原創(chuàng)]設(shè)計模型探索L-composite parttern之玉樹臨風(fēng)
[原創(chuàng)]設(shè)計模型探索K-builder parttern之各施其職
Powered by:
BlogJava
Copyright © HUIKK
主站蜘蛛池模板:
拔擦拔擦8x华人免费久久
|
亚洲成人黄色在线
|
免费观看的毛片手机视频
|
99视频在线免费看
|
最新欧洲大片免费在线
|
国产大片51精品免费观看
|
久久影院亚洲一区
|
亚洲天堂男人天堂
|
亚洲综合激情五月色一区
|
免费国产草莓视频在线观看黄
|
中文字幕乱码系列免费
|
**一级一级毛片免费观看
|
午夜免费福利影院
|
国产亚洲精品免费视频播放
|
精品亚洲成AV人在线观看
|
67pao强力打造67194在线午夜亚洲
|
亚洲国产成a人v在线观看
|
亚洲一区二区三区亚瑟
|
亚洲宅男天堂a在线
|
亚洲AV香蕉一区区二区三区
|
和老外3p爽粗大免费视频
|
色噜噜亚洲精品中文字幕
|
亚洲成人在线网站
|
亚洲乱码av中文一区二区
|
aaa毛片免费观看
|
免费在线看v网址
|
中文字幕无码不卡免费视频
|
亚洲黄黄黄网站在线观看
|
亚洲视频一区调教
|
日日摸日日碰夜夜爽亚洲
|
久久大香伊焦在人线免费
|
青青草国产免费久久久91
|
亚洲精品V欧洲精品V日韩精品
|
亚洲AV无码乱码麻豆精品国产
|
丁香六月婷婷精品免费观看
|
1000部夫妻午夜免费
|
久久精品国产亚洲Aⅴ蜜臀色欲
|
亚洲午夜久久久久久尤物
|
黄色视频在线免费观看
|
成年女人午夜毛片免费看
|
免费又黄又硬又爽大片
|