Оцените презентацию от 1 до 5 баллов!
Тип файла:
ppt / pptx (powerpoint)
Всего слайдов:
26 слайдов
Для класса:
1,2,3,4,5,6,7,8,9,10,11
Размер файла:
487.17 kB
Просмотров:
68
Скачиваний:
0
Автор:
неизвестен
Слайды и текст к этой презентации:
№1 слайд![Structured Exceptions](/documents_6/96f037be39aba7f53f94594da6d986cc/img0.jpg)
Содержание слайда: Structured Exceptions Handling in .NET
V'yacheslav Koldovskyy
SoftServe University
2014
№2 слайд![Contents](/documents_6/96f037be39aba7f53f94594da6d986cc/img1.jpg)
Содержание слайда: Contents
№3 слайд![. Introduction to structured](/documents_6/96f037be39aba7f53f94594da6d986cc/img2.jpg)
Содержание слайда: 1. Introduction to structured exception handling
№4 слайд![Main task correct operation](/documents_6/96f037be39aba7f53f94594da6d986cc/img3.jpg)
Содержание слайда: Main task – correct operation of the application
There are possible situations during the application execution when predetermined plan of actions may be changed
Developer should provide ways to ensure correct execution despite possible errors
№5 слайд![Obsolete check-based method](/documents_6/96f037be39aba7f53f94594da6d986cc/img4.jpg)
Содержание слайда: Obsolete check-based method
Obsolete error handling method is based on multiple checks of input data and operation return codes.
Drawbacks:
difficulties;
bloated code;
unreliable.
№6 слайд![Structured exception handling](/documents_6/96f037be39aba7f53f94594da6d986cc/img5.jpg)
Содержание слайда: Structured exception handling
Modern way to handle errors provides using of special mechanism – structured exception handling which is the part of programming language
Exception is an event which happens during software execution and changes normal way of code execution
Exceptions in .NET Framework are instances of classes inherited from base class Exception. Only instances of this class and inherited classes may participated in structured exception handling.
№7 слайд![. Construct try..catch](/documents_6/96f037be39aba7f53f94594da6d986cc/img6.jpg)
Содержание слайда: 2. Construct «try..catch»
№8 слайд![Simplest quot try..catch quot](/documents_6/96f037be39aba7f53f94594da6d986cc/img7.jpg)
Содержание слайда: Simplest "try..catch" constuct
try
{
// Code which may result in exception
}
catch
{
// Code executed only in case of exception
}
№9 слайд![quot try..catch quot](/documents_6/96f037be39aba7f53f94594da6d986cc/img8.jpg)
Содержание слайда: "try..catch" construct with specific exception
try
{
// Code which may result in exception
}
catch (DivideByZeroException)
{
// Code executed in case of exception
}
№10 слайд![Cascade sections of catch try](/documents_6/96f037be39aba7f53f94594da6d986cc/img9.jpg)
Содержание слайда: Cascade sections of catch
try
{
// Code which may result in exception
catch (DivideByZeroException)
{
// Code executed in case of exception type DivideByZeroException
}
catch (Exception)
{
// Code executed in case of exception type Exception
// Means "any exception"
}
№11 слайд![quot try..catch quot](/documents_6/96f037be39aba7f53f94594da6d986cc/img10.jpg)
Содержание слайда: "try..catch" construct with instance of exception
№12 слайд![. Exception class and](/documents_6/96f037be39aba7f53f94594da6d986cc/img11.jpg)
Содержание слайда: 3. «Exception» class and exception hierarchy in.NET Framework
№13 слайд![Exception class Exception is](/documents_6/96f037be39aba7f53f94594da6d986cc/img12.jpg)
Содержание слайда: Exception class
Exception is a base class for all exceptions исключений
Important properties:
Message – user-oriented message about error
Source – name of an error source (application or object)
InnerException – inner exception (if called from other)
StackTrace – call stack to the point of exception call
TargetSite – method name which raised an exception
HelpLink – URL-address to information about exception
Data – dictionary with additional information with exception (IDictionary)
№14 слайд![Exception hierarchy in .NET](/documents_6/96f037be39aba7f53f94594da6d986cc/img13.jpg)
Содержание слайда: Exception hierarchy in .NET Framework
№15 слайд![. Exception throwing and](/documents_6/96f037be39aba7f53f94594da6d986cc/img14.jpg)
Содержание слайда: 4. Exception throwing and re-rising
№16 слайд![Exception throwing](/documents_6/96f037be39aba7f53f94594da6d986cc/img15.jpg)
Содержание слайда: Exception throwing
№17 слайд![Exception re-rising](/documents_6/96f037be39aba7f53f94594da6d986cc/img16.jpg)
Содержание слайда: Exception re-rising
№18 слайд![. Creating own exceptions](/documents_6/96f037be39aba7f53f94594da6d986cc/img17.jpg)
Содержание слайда: 5. Creating own exceptions
№19 слайд![Exception declaration](/documents_6/96f037be39aba7f53f94594da6d986cc/img18.jpg)
Содержание слайда: Exception declaration
№20 слайд![MSDN recommendations for](/documents_6/96f037be39aba7f53f94594da6d986cc/img19.jpg)
Содержание слайда: MSDN recommendations for exception declarations
№21 слайд![. Construct try..finally](/documents_6/96f037be39aba7f53f94594da6d986cc/img20.jpg)
Содержание слайда: 6. Construct «try..finally»
№22 слайд![Using finally try..finally](/documents_6/96f037be39aba7f53f94594da6d986cc/img21.jpg)
Содержание слайда: Using finally
«try..finally» used when it is required to guarantee execution of some code
May be used together with catch
№23 слайд![. Best practices for](/documents_6/96f037be39aba7f53f94594da6d986cc/img22.jpg)
Содержание слайда: 7. Best practices for exception handling
№24 слайд![Best practices for exception](/documents_6/96f037be39aba7f53f94594da6d986cc/img23.jpg)
Содержание слайда: Best practices for exception handling
Do not catch general exceptions (do not use catch without parameters or catch(Exception) )
Create own exceptions based on ApplicationException class but not on SystemException
Do not use exceptions for application execution control flow as exception handling is heavy resource usage task. Exceptions should be used to manage errors only
Do not mute exceptions which can’t be handled in application context (system errors and failures).
Do not raise general exceptions: Exception, SystemException, ApplicationException
Do not generate reserved system exceptions: ExecutionEngineException, IndexOutOfRangeException, NullReferenceException, OutOfMemoryException
Do not return an exception instance as a method return result instead of using throw.
Do not create exceptions used only for debugging purposes. Do define debug-only exceptions use Assert.
№25 слайд![. References to additional](/documents_6/96f037be39aba7f53f94594da6d986cc/img24.jpg)
Содержание слайда: 8. References to additional sources
MSDN recommendations for creating exceptions:
http://msdn.microsoft.com/en-us/library/ms173163.aspx
MSDN recommendation for exception generation:
http://msdn.microsoft.com/en-us/library/ms182338.aspx
Full hierarchy of Microsoft .NET Framework exceptions (code sample in comments): http://stackoverflow.com/questions/2085460/c-sharp-is-there-an-exception-overview
№26 слайд![Contacts](/documents_6/96f037be39aba7f53f94594da6d986cc/img25.jpg)
Содержание слайда: Contacts