CLR via C# by Richter Jeffrey
Author:Richter, Jeffrey [Jeffrey Richter]
Language: eng
Format: epub
Tags: COMPUTERS / Programming Languages / C#
ISBN: 9780735642812
Publisher: Microsoft Press
Published: 2010-02-04T16:00:00+00:00
Note
There are two issues to note about my Exception<TExceptionArgs> class. The first issue is that any exception type you define with it is always derived from System.Exception. In most scenarios, this is not a problem at all and, in fact, having a shallow and wide exception type hierarchy is preferred. The second issue is that Visual Studio's unhandled exception dialog box doesn't display Exception<T> type's generic type parameter, as you can see here:
Trading Reliability for Productivity
I started writing software in 1975. I did a fair amount of BASIC programming, and as I got more interested in hardware, I switched to assembly language. Over time, I switched to the C programming language because it allowed me access to hardware with a much higher level of abstraction, making my programming easier. My background is in writing operating systems code and platform/library code, so I always work hard to make my code as small and as fast as possible since applications can only be as good as the OS and libraries they consume.
In addition to creating small and fast code, I always focused on error recovery. When allocating memory (by using C++'s new operator or by calling malloc, HeapAlloc, VirtualAlloc, etc.), I would always check the return value to ensure that the memory I requested was actually given to me. And, if the memory request failed, I always had an alternate code path ensuring that the rest of the program's state was unaffected and would let any of my callers know that I failed so that the calling code can take corrective measures too.
For some reason that I can't quite explain, this attention to detail is not done when writing code for the .NET Framework. Getting an out-of-memory situation is always possible and yet I almost never see any code containing a catch block to recover from an OutOfMemoryException. In fact, I've even had some developers tell me that the CLR doesn't let a program catch an OutOfMemoryException. For the record, this is absolutely not true; you can catch this exception. In fact, there are many errors that are possible when executing managed code and I hardly ever see developers write code that attempts to recover from these potential failures. In this section, I'd like to point out some of the potential failures and why it has become culturally acceptable to ignore them. I'd also like to point out some of the significant problems that can occur when ignoring these failures and suggest some ways to help mitigate these problems.
Object-oriented programming allows developers to be very productive. A big part of this is composability which makes it easy to write, read and maintain code. Take this line of code, for example:
Boolean f = "Jeff".Substring(1, 1).ToUpper().EndsWith("E");
There is a big assumption being made with the code above: no errors occur. But, of course, errors are always possible, and so we need a way to handle those errors. This is what the exception handling constructs and mechanisms are all about and why we need them as
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(12571)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8299)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7082)
Microservices with Go by Alexander Shuiskov(6849)
Practical Design Patterns for Java Developers by Miroslav Wengner(6769)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6708)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6416)
Angular Projects - Third Edition by Aristeidis Bampakos(6114)
The Art of Crafting User Stories by The Art of Crafting User Stories(5644)
NetSuite for Consultants - Second Edition by Peter Ries(5576)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5381)
Kotlin in Action by Dmitry Jemerov(5065)
