当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

复旦大学:《面向对象分析和设计》课程资料_Error Handling

资源类别:文库,文档格式:PDF,文档页数:36,文件大小:907.11KB,团购合买
点击下载完整版文档(PDF)

Error Handling OOA/OOD xuyingxiao@126.com

Error Handling OOA/OOD xuyingxiao@126.com

Error Handling patterns Big Outer Try Block Hide Technical Detail from Users Log at Distribution Log Unexpected Boundary Errors Unique Error Split Domain and Make Exceptions Identifier Technical errors Exceptional

Error Handling Patterns

plit Domain and Technical Errors domain errors'' are due to errors in the business logic or business processing(e. g. wrong type of customer for insurance policy) technical errors", are caused by problems in the underlying platform(e.g, could not connect to database)or by unexpected faults(e.g. divide by zero e Handling technical errors in domain code makes this code more obscure and difficult to maintain

Split Domain and Technical Errors “domain errors”, are due to errors in the business logic or business processing (e.g. wrong type of customer for insurance policy). “technical errors”, are caused by problems in the underlying platform (e.g. could not connect to database) or by unexpected faults (e.g. divide by zero). Handling technical errors in domain code makes this code more obscure and difficult to maintain

e Solution Split domain and technical error handling Create separate exception/error hierarchies and handle at different points and in different ways as approprlate

Solution Split domain and technical error handling. Create separate exception/error hierarchies and handle at different points and in different ways as appropriate

Domain Exception System exception CustomerNotFound Exception InsufficientFunds Exception Transaction Refused Exception

e public class DomainEXception extends Exception Public class InsufficientFunds Exception extends . Exception public class SystemEXception extends Exception

public class DomainException extends Exception { ... } Public class InsufficientFundsException extends …Exception { ... } public class SystemException extends Exception { ... }

public float withdrawFunds (float amount e throws InsufficientFunds Exception, SystemException Domain code that could generate various errors both technical and domain catch(Domain Exception ex throw ex catch(Exception ex) throw new SystemException(ex)

public float withdrawFunds(float amount) throws InsufficientFundsException, SystemException { try { // Domain code that could generate various errors // both technical and domain } catch (DomainException ex) { throw ex; } catch (Exception ex) { throw new SystemException(ex); } }

Error Handling patterns Big Outer Try Block Hide Technical Detail from Users Log at Distribution Log Unexpected Boundary Errors Unique Error Split Domain and Make Exceptions Identifier Technical errors Exceptional

Error Handling Patterns

Big outer Try Block e Errors will propagate right to the edge of the system and will appear to crash the application if not handled at that point e Users are mostly on remote sites and will not do much to report errors

Big Outer Try Block Errors will propagate right to the edge of the system and will appear to “crash” the application if not handled at that point. Users are mostly on remote sites and will not do much to report errors

e Solution e Implement a Big Outer Try Block at the "edge" of the system to catch and handle errors that cannot be handled by other tiers of the system. The error handling in the block can report errors in a consistent way at a level of detail appropriate to the user constituency

Solution Implement a Big Outer Try Block at the “edge” of the system to catch and handle errors that cannot be handled by other tiers of the system. The error handling in the block can report errors in a consistent way at a level of detail appropriate to the user constituency

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共36页,可试读12页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有