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 126113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:15:58+00:00 2026-05-11T05:15:58+00:00

DUPE: Private vs. Public members in practice (how important is encapsulation?) In the course

  • 0

DUPE: Private vs. Public members in practice (how important is encapsulation?)

In the course of writing a program in Java, I have abstracted out some libraries that I can see a possible use for in future projects.

Why should I bother with setting restricted access (private/protected) on any of these methods?

It seems like this will just make my life more complicated in the future. If I use public on everything, I will never need to worry about whether I can call something from some other class. I have never seen a case in any of my code yet where it made any sense for me to use anything except public.

Is it so wrong to use ‘public’ on everything? Am I going to be struck down by the Java gods?

  • 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-11T05:15:58+00:00Added an answer on May 11, 2026 at 5:15 am

    Yes, it’s wrong to use public on everything. It means you have absolutely no concept of the difference between ‘this member is part of a public API; you’re expected to be able to use it from the outside world, and it shouldn’t change’ and ‘this member is an implementation detail. If I want to change it later, I can do so because I know nothing from the outside world will be calling it.’

    Having a clear split between API and implementation is important for flexibility and clarity IMO.

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

Sidebar

Related Questions

Update : this is more-or-less a dupe , and it turns out to be
Say I have the following class: public MainFormViewModel { public String StatusText {get; set;}
at our company we have some drupal projects that share some custom developed modules,
Dupe: Null Difference A lifetime ago I came across an article that explained that
DUPE: Any Yahoo YUI validation framework that I can implement in asp.net MVC? Has
DUPE: Should 'using' statements be inside or outside the namespace? If I add a
I am parsing some XML something like this: <root> <some_gunk/> <dupe_node> ... stuff I
Related (but not a dupe!) to this question: Help with the WPF TextCompositionManager events
This is similar to What happens when you run a program? , but not
Related: How do I create a static local variable in Java? Pardon if this

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.