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

正文內(nèi)容

第11講架構(gòu)與其他模式(編輯修改稿)

2024-11-03 16:41 本頁面
 

【文章內(nèi)容簡介】 tion 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 file] : ps := getSpecification(id) continued in another diagram IProductsAdapter Shanghai Jiaotong University 處理故障 ?本地緩存中未命中且訪問外部產(chǎn)品服務(wù)失敗時(shí),如何處理 ? ? 用信號通知收銀員人工輸入價(jià)格和描述 ? ? 取消輸入該商品項(xiàng) ? ?解決方案 : 拋出異常 ? 低層的異常轉(zhuǎn)換成高層次中有意義的異常 ? 依據(jù)問題而不是拋出者命名異常 2020/11/4 42 Shanghai Jiaotong University 處理錯(cuò)誤 (seq diagram) 2020/11/4 43 exception DBUnavailableException() : DBProducts Adapter IProductsAdapter : Persistence Facade UML notation : * All asynchronous messages, including exceptions, are illustrated with a stick arrowhead. * Exceptions are shown as messages indicated by the exception class name. * An optional exception or signal stereotype is legal (an exception is a kind of signal in the UML), if increased visibility is desired. ps := get(...) ps := getSpecification(id) : Object resultSet := executeQuery(...) exception SQLException() note the difference between synchronous and asynchronous message arrowheads in the UML recall that indicating the instance of type Object is useful when one wants to indicate the interface, but not the class of an instance exception ProductInfoUnavailableException() stopping the message line at this point indicates the PersistenceFacade object is catching the exception Shanghai Jiaotong University Exceptions in a UML class diagram 2020/11/4 44 exceptions caught are modeled as a kind of operation handling a signal PersistenceFacade usageStatistics : Map Object get(Key, Class) throws DBUnavailableException, FatalException put(Key, Object) { throws= (DBUnavailableException, FatalException) } ... 玸 ignal?SQLException() 玸 ignal?IOException() exceptions FatalException DBUnavailableException exceptions thrown can be listed in another partment labeled exceptions UML notation : The UML has a default syntax for operations. But it does not include an official solution to show exceptions thrown by an operation. There are at least three solutions: 1. The UML allows the operation syntax to be any other language, such as Java. In addition, some UML CASE tools allow display of operations explicitly in Java , Object get(Key, Class) throws DBUnavailableException, FatalException 2. The default syntax allows the last element to be a property string. This is a list of arbitrary property+value pairs, such as { author=Craig, kids=(Hannah, Haley), ...}. Thus, put(Object, id) { throws= (DBUnavailableException, FatalException) } 3. Some UML CASE tools allow one to specify (in a special dialog box) the exceptions that an operation throws. Shanghai Jiaotong University 更多模式 ?轉(zhuǎn)換異常 ?對問題而不是拋出者命名 ?集中錯(cuò)誤日志 ?錯(cuò)誤會話 ?代理 ?抽象工廠 ?自力更生 2020/11/4 45 Shanghai Jiaotong University (1)轉(zhuǎn)換異常 ?將較低層的異常轉(zhuǎn)換為本層次系統(tǒng)中有意義的異常 ? 通過轉(zhuǎn)換,高層次的異常提供了對低層次異常的子系統(tǒng)層次的解釋 2020/11/4 46 Shanghai Jiaotong University (2)命名問題,而不是拋出者 ?異常必須依據(jù)其拋出的理由進(jìn)行命名 ?拋出者并不能表示問題所在 2020/11/4 47 Shanghai Jiaotong University (3)集中錯(cuò)誤日志 ?使用單實(shí)例類訪問的集中錯(cuò)誤日志對象,所有的異常都向它匯報(bào) ? 提供了一致性 ? 對輸出流和格式的柔性定義 2020/11/4 48 Shanghai Jiaotong University (4)錯(cuò)誤會話 ?使用標(biāo)準(zhǔn)的單實(shí)例類訪問的、應(yīng)用程序無關(guān)的、非用戶界面的對象向用戶通知錯(cuò)誤。 ? 對輸出機(jī)制的變化實(shí)現(xiàn)了防止變異 ? 一致的錯(cuò)誤匯報(bào)風(fēng)格 ? 集中控制公共的錯(cuò)誤通知策略 ? 性能也有所改進(jìn) 2020/11/4 49 Shanghai Jiaotong University 處理異常 2020/11/4 50 : DBProducts Adapter : Local Products IProductsAdapter :ProductCatalog ps := getSpec(id) :Register enterItem(id, qty) :ProcessSale Frame exception ProductInfoUnavailableException() singleton :ErrorDialog notify(message, exception) ps := getSpec(id) ps := getSpec(id) continued singleton :ErrorDialog notify (message, exception) * : notify(message) : Object : Object INotifier GUI dialog box text console dialog speech dialog singleton :Log log(exception) IProductsAdapter Convert Exception pattern Error Dialog pattern Centralized Error Logging pattern Shanghai Jiaotong University (5)代理 (GoF) ?問題 : 不希望或不可能直接訪問真正的主題對象時(shí),應(yīng)該如何 ?解決方案 : 通過代理對象增加一層間接性,代理對象實(shí)現(xiàn)與主題對象相同的接口,并且負(fù)責(zé)控制和增強(qiáng)對主題對象的訪問 2020/11/4 51 Shanghai Jiaotong University Proxy 結(jié)構(gòu) 2020/11/4 52 interface ISubjectInterface foo() RealSubject foo() { ... preprocessing () ... postprocessing } Client subject : ISubjectInterface doBar() 1 1 1 1 Proxy realSubject : ISubjectInterface foo() { ... whatev
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1