freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

第11講架構(gòu)與其他模式(參考版)

2024-10-02 16:41本頁面
  

【正文】 n o t i n D BO l d r e t r i e v e d f r o m D BC l e a n u n m o d i f i e dD i r t y m o d i f i e dD e l e t e dShanghai Jiaotong University 狀態(tài)模式( State Pattern) ?問題: Behavior depends on state of an object. How to avoid conditional logic? ?解決方案 : Create stateclasses for each state, with a mon interface. Delegate statedependent operations to the state class 2020/11/4 71 Shanghai Jiaotong University 2020/11/4 72 P e r s i s t e n t O b j e c to i d : O I Ds t a t e : P O b j e c t S t a t ec o m m i t ( )d e l e t e ( )r o l l b a c k ( )s a v e ( )s e t S t a t e ( P O b j e c t S t a t e ). . .P O b j e c t S t a t ec o m m i t ( o b j : P e r s i s t e n t O b j e c t )d e l e t e ( o b j : P e r s i s t e n t O b j e c t )r o l l b a c k ( o b j : P e r s i s t e n t O b j e c t )s a v e ( o b j : P e r s i s t e n t O b j e c t )O l d D i r t yS t a t ec o m m i t ( . . . )d e l e t e ( . . . )r o l l b a c k ( . . . )1O l d C l e a nS t a t ed e l e t e ( . . . )s a v e ( . . . )N e wS t a t ec o m m i t ( . . . )O l d D e l e t eS t a t ec o m m i t ( . . . )r o l l b a c k ( . . . )P r o d u c tS p e c i f i c a t i o n. . .. . .S a l e. . .. . .*{ s t a t e . d e l e t e ( t h i s ) }{ / / d e f a u l t n o o p / / b o d i e s f o r / / e a c h m e t h o d}{ / / d e l e t eo b j . s e t S t a t e ( O l d D e l e t e S t a t e . g e t I n s t a n c e ( ) ) }{ / / s a v eo b j . s e t S t a t e ( O l d D i r t y S t a t e . g e t I n s t a n c e ( ) ) }{ / / r o l l b a c kP e r s i s t e n c e F a c a d e . g e t I n s t a n c e ( ) . r e l o a d ( o b j )o b j . s e t S t a t e ( O l d C l e a n S t a t e . g e t I n s t a n c e ( ) ) }{ / / c o m m i tP e r s i s t e n c e F a c a d e . g e t I n s t a n c e ( ) . u p d a t e ( o b j )o b j . s e t S t a t e ( O l d C l e a n S t a t e . g e t I n s t a n c e ( ) ) }{ s t a t e . r o l l b a c k ( t h i s ) }{ s t a t e . c o m m i t ( t h i s ) }{ s t a t e . s a v e ( t h i s ) }{ / / c o m m i tP e r s i s t e n c e F a c a d e . g e t I n s t a n c e ( ) . i n s e r t ( o b j )o b j . s e t S t a t e ( O l d C l e a n S t a t e . g e t I n s t a n c e ( ) ) }{ / / c o m m i tP e r s i s t e n c e F a c a d e . g e t I n s t a n c e ( ) . d e l e t e ( o b j )o b j . s e t S t a t e ( D e l e t e d S t a t e . g e t I n s t a n c e ( ) ) }Shanghai Jiaotong University 命令模式( Command Pattern) ?問題 : How to handle a multiplicity of requests/tasks that occur in a runtimedependent order? (such as the various operations that can occur in a transaction) ?解決方案 : Make each request a class that implements the same interface 2020/11/4 73 Shanghai Jiaotong University 2020/11/4 74 玦 n t e r f a c e ?I C o m m a n de x e c u t e ( )u n d o ( )D B I n s e r t C o m m a n de x e c u t e ( )D B U p d a t e C o m m a n de x e c u t e ( )D B D e l e t e C o m m a n de x e c u t e ( )T r a n s a c t i o nc o m m a n d s : L i s tc o m m i t ( )a d d D e l e t e ( o b j : P e r s i s t e n t O b j e c t )a d d I n s e r t ( o b j : P e r s i s t e n t O b j e c t )a d d U p d a t e ( o b j : P e r s i s t e n t O b j e c t )s o r t ( ). . .1 . .*D B C o m m a n do b j e c t : P e r s i s t e n t O b j e c te x e c u t e ( ) { a b s t r a c t }u n d o ( ) { l e a f }u n d o i s a n o o p f o rt h i s e x a m p l e , b u t am o r e c o m p l e xs o l u t i o n a d d s ap o l y m o r p。 dbRec = SQL execution result of: Select * from + tableName + where key = + key return dbRec。 return ps。 ( (ITEM_ID) )。 ( oid )。constructor187。 // hook method return getObjectFromRecord( oid, dbRec )。constructor187。interface187。 Z e n M u m b a iM A N U F A C T U R E R T A B L E: M a n u f a c t u r e rc i t y = M u m b a in a m e = N o w amp。 Z e n Mu mb a iMA N U F A C T U R E R T A B L E: Ma n u f a c t u r e rn a m e = N o w amp。ade object 2020/11/4 36 adds a level of indirection to Domain Presentation Register Sale ProcessSale Frame UIFacade UIFacades are occasionally used when a pushfrombelow munication model is required. Not a Swing or GUI class. Just a plain object which the GUI objects Shanghai Jiaotong University 3. 更多模式 Shanghai Jiaotong University ?使用模式解決某些實(shí)際問題 : ? Reliability and recovery ?Local caching ?Handling failure ? Handling payments ? 7個(gè)新模式 2020/11/4 38 Shanghai Jiaotong University 采用適配器和多態(tài)模式實(shí)現(xiàn)緩存 2020/11/4 39 interface IProductsAdapter getSpecification( itemID ) : ProductSpecification DBProductsAdapter getSpecification( itemID ) LocalProducts remoteProductsService: IProductAdapter getSpecification( itemID ) BigWebServiceProductsAdapter getSpecification( itemID ) 1 1 Implements the adapter interface, but is not really an adapter for a second ponent. Rather, it itself implements the local service function. ProductCatalog productsService : IProductAdapter getSpecification() 1 1 Shanghai Jiaotong University Singleton 和 Factory 提供了實(shí)現(xiàn)接口的類 2020/11/4 40 :Store :Register pc: ProductCatalog create() 2: create(pc) 1: create() singleton :ServicesFactory psa : LocalProducts externalService : DBProductsAdapter : psa := getProductsAdapter() IProductsAdapter : create( externalService ) : create() 本地服務(wù)獲取了對外部服務(wù)的適配器的引用 IProductsAdapter 返回本地服務(wù) Shanghai Jiaotong University 從緩存或者數(shù)據(jù)庫中獲取產(chǎn)品信息 2020/11/4 41 : LocalProducts remoteService : DBProductsAdapter IProductsAdapter : KeyIndexedFileOf SerializedObjects 1: ps := get( id ) 3 [not in file ]: put( id, ps ) ps := getSpecification(id) 2 [not in fil
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1