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

  • Home
  • SEARCH
  • 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 1111813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:36:26+00:00 2026-05-17T02:36:26+00:00

I believe that it’s better to code to interfaces instead of implementations. In Java:

  • 0

I believe that it’s better to code to interfaces instead of implementations. In Java:

List<User> users = new ArrayList<User>();

There’s no need to specify the runtime type of users all over the program if the code only cares that it implements List.

However, I encounter many people who believe that it’s totally fine, even when they’re not using properties specific to the ArrayList:

ArrayList<User> users = new ArrayList<User>();

I try to explain that it’s redundancy and makes the program harder to change, but they don’t seem to care. Are there other reasons that this is important? Or perhaps my convictions are overstated?

  • 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. Editorial Team
    Editorial Team
    2026-05-17T02:36:27+00:00Added an answer on May 17, 2026 at 2:36 am

    Personally, I think that there are two parts to this argument.

    1. If you’re returning an object from a method in a class, it should return the most generic object possible. In this case, if you had a choice between returning ArrayList<User> or List<User>, return List<User> because it makes life easier for the people consuming your class.

    2. If you’re coding inside of a method and you don’t mind hard-coding a concrete type, go for it. It’s not what I would do, and it will make your code more fragile in the future but since there are no outside dependencies on that concrete type (hence the first part), you’re not going to break anybody that is consuming your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe that out there we have algorithms implementations (e.g. a c++ implementation of
I am beginning to believe that unit testing high level, well-written code, which requires
I believe that it's possible to call Java methods from (PhoneGap) Javascript. Anyone knows
I strongly believe that, reading code and reading good code is key to great
I'm using libsvm and the documentation leads me to believe that there's a way
I believe that all the source code in the Android framework could be found
I believe that I have successfully impersonated my own user account while running an
Premise I believe that there is a way to objectively define "Good" and "Bad"
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Atomic-Builtins.html I believe that the following code increases the value of var atomically. volatile
I believe that IDictionary classes works better with sortable objects. I believe also that

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.