Tagged: #exceptions

Java try-with-resources

Java 7 supports a new statement called try-with-resources which extends the behavior of the traditional try/catch block for the sake of automatic resource management, since Java 7 developers are able to access resources (files, db connections, sockets) inside a try-with-resources block without the need to worry about closing them afterwards, the resource closure is done automatically. 1. Resource management using traditional...

Exception handling strategy

In this article we introduce a common strategy for handling exceptions in an OOP application, our strategy conforms to the best exception handling techniques and can be integrated in any application. 1. Overview The following diagram provides an overview of our strategy, it shows the flow of the exception starting from the detection phase until reaching the handling phase. The...

How to use exceptions effectively

Exception is an event which occurs during the execution of a program and disrupts its normal flow, it is mainly arrised from different kind of situations such as wrong user interaction, hardware failure, network failure, database failures or even business failures. 1. Checked vs Unchecked Exceptions are of 2 types: checked and unchecked. Checked exceptions are predictable during the development...