DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Coding Crimes: Ignoring Exceptions

James Sugrue user avatar by
James Sugrue
CORE ·
Jun. 14, 10 · Interview
Like (0)
Save
Tweet
Share
15.85K Views

Join the DZone community and get the full member experience.

Join For Free

Templates in IDEs such as Eclipse and NetBeans are a great feature. In particular, quick fix items such as "surround with try/catch" can save a lot of typing time. But, as with all things, the power given to the developer can be mis-used. This has got to be one of the worst coding crimes. 

Depending on your IDE and the templates you use, you'll probably get this: 

try 
{

} catch (Exception e)
{
// TODO: handle exception
}

Or, maybe you'll at least get the exception written out to console.

try 
{

} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

For a start, the exception should be logged at the very least, not just written out to the console.  Also, in most cases, the exception should be thrown back to the caller for them to deal with. If it doesn't need to be thrown back to the caller, then the exception should be handled. And some comments would be nice too. 

The usual excuse for this type of code is "I didn't have time", but there is a ripple effect when code is left in this state. Chances are that most of this type of code will never get out in the final production. Code reviews or static analysis tools should catch this error pattern. But that's no excuse, all this does is add time to the maintainance and debugging of the software.  This also makes you question TODOs, and brings me back to my previous thoughts on writing the best code from the very start. 

Coding (social sciences)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Cloud
  • Apache Kafka Is NOT Real Real-Time Data Streaming!
  • How To Build an Effective CI/CD Pipeline
  • Cucumber.js Tutorial With Examples For Selenium JavaScript

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: