Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 131563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:07:30+00:00 2026-05-11T06:07:30+00:00

I am mulling over the idea of writing a program to check for leaky

  • 0

I am mulling over the idea of writing a program to check for ‘leaky abstractions’ in Java. The one area that popped into mind right away is with exceptions:

public class X {     // this one is fine, Readers throw IOExceptions so it is      // reasonable for the caller to handle it     public void parse(final Reader r)         throws IOException     {     }      // This one is bad.  Nothing in the API indicate that JDBC      // is being used at all.     public void process()         throws SQLException     {            } } 

Note, I do not want an argument on relative merits of checked/unchecked exceptions. What I am looking for is other examples (doesn’t have to be exception handling) that people have that could also be reasonably caught via examining the source code or class files.

I am aware of checkstyle, findbugs, and PMD, and AFAIK none of them deal with this (and I am not opposed to putting the checks into one of those tools rather than write my own).

Are there any other examples of leaky abstractions that you come to mind that could be statically check for?

EDIT:

The reason why the second one is bad is that the method throws an exception where the client has no way of knowing that JDBC (for example, it could be anything) is being used. So the ‘leaky abstraction’ is that JDBC is being used. If the underlying mechanism changed to soemthing else (say JPA which is a different database abstraction library) then the exceptions would all need to change as well. So the underlying database library is being leaked out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:07:31+00:00Added an answer on May 11, 2026 at 6:07 am

    So.

    How to detect if an API leaks implementation details or does not keep the same level of abstraction.

    You may probably watch the this talk. It explains how good APIs look like and are designed ( you can deduct from the good practices what are the bad practices )

    For instance

    Functionality should be easy to explain. If its a hard name it’s generally a bad design.

    From that you could discover, if the methods or return parameters give detail instructions they are not along with the level of abstraction.

    For instance a high level method

     -initProcess(): SGN_MTL 

    May be leaking implemntation details on the return value.

    The hard part here is to detect when the level of abstraction changes.

    For instance in your method it would be ok to throw SQLExceptions all around if the code it self is the implementation of the JDCB layer.

    Other source where you can see more of these topics is this list. http://www.jetbrains.com/idea/documentation/inspections.jsp

    See the items under ‘Abstraction’ ie.

    • Instance variable of concrete class: Report when the type of an instance variable is declared as a concrete class rather than an interface.

    The classic example is:

     private ArrayList list; 

    when it will be better

     private List list; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been mulling over writing a peak-fitting library for a while. I know
I am new to Spring Security and am mulling over the idea of using
I had an idea I was mulling over with some colleagues. None of us
I've been mulling over how one would go about creating a P2P system (like
I've been mulling over creating a language that would be extremely well suited to
I am mulling over a best practice for passing hash references for return data
I've spent some time casually mulling over ACLs in my head. I can see
Mulling over something I've been reading up on. According to Chris Webb , A
So recently I was given a problem, which I have been mulling over and
I have this idea I've been mulling around in my head based on another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.