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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:17:42+00:00 2026-05-27T11:17:42+00:00

I stumbled upon a small library which has some classes in four packages and

  • 0

I stumbled upon a small library which has some classes in four packages and one basic class that should be used by who ever will use this library.

I had to review this library and suggested, that the access to some classes and methods should be restricted as the user should only see methods/classes that he really should use. In this case it should be one class with a few methods that can be called.

While my suggestion just popped into my mind, I couldn’t get a real solution on how to do that.

The first ugly idea was: Put the public class in package a and everything else in package a.b which isn’t a good idea.

The package structure prevent the protected modifier as classes in package a.b need to call methods from a class in package a.c. So is there a pattern that can be used to prevent that someone is instantiating a class inside a.b and call their public methods?

If the description of the problem wasn’t good enough, feel free to ask in the comments. Thanks.

  • 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-27T11:17:43+00:00Added an answer on May 27, 2026 at 11:17 am

    Put classes that you don’t want other people to see with default modifier ( basically with no modifier at all ). This will make them package-private.

    All classes inside the package will be able to see and use them, but nobody outside the library would be able to instantiate and use them without reflection cheats.

    This implies that library should use a single package.

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

Sidebar

Related Questions

I stumbled upon some code the other day that was making use of query
I stumbled upon this article http://www.thefloatingfrog.co.uk/css/my-hatred-of-br-clearall/ When would one need to use that ?
In a python source code I stumbled upon I've seen a small b before
I stumbled upon this question: 7 power 7 is 823543. Which higher power of
I just stumbled upon MainSoft's Grasshopper , which claims to cross-compile .Net ILM to
i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.
I stumbled upon this add-on which Ajaxifies parts of its target website. https://addons.mozilla.org/en-US/firefox/addon/51789 I
I stumbled upon a problem where i need an instance of the class inside
I stumbled upon this piece of code which seems totaly broken to me, but
I stumbled upon a tool that generates P/Invoke signatures for Microsoft's own unmanaged DLLs:

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.