May-05-2023, 06:56 AM
I am developing a bigger project that includes some data structures as classes and various functions/operations that computes with the structure of modifies them.
My dilemma is the following:
I have a bunch of methods inside the class that allow the users to interact with the structure,
but there are many common private methods that get called from the public methods,
lets call one
I don't want the users to call these directly, since they can be misused and can make the structure not make sense.
But then my package has a lot subpackages that contain functions that perform various operations and computations on the structure,
here I call the private methods
since the functions need these operations. But my IDE is not happy about me accessing private methods.
I see two solutions:
1. ignore the IDE warnings. The functions are part of the package that contains the class, so I call private methods from outside, but the end used shold not access them.
2. Make all such methods public and allow the end user to call the methods which can render the whole instance non-sensical.
What do you guys think?
My dilemma is the following:
I have a bunch of methods inside the class that allow the users to interact with the structure,
but there are many common private methods that get called from the public methods,
lets call one
_remove_something_from_structure()
and _modify_something_from_structure()
.I don't want the users to call these directly, since they can be misused and can make the structure not make sense.
But then my package has a lot subpackages that contain functions that perform various operations and computations on the structure,
here I call the private methods
_remove_something_from_structure()
and _modify_something_from_structure()
,since the functions need these operations. But my IDE is not happy about me accessing private methods.
I see two solutions:
1. ignore the IDE warnings. The functions are part of the package that contains the class, so I call private methods from outside, but the end used shold not access them.
2. Make all such methods public and allow the end user to call the methods which can render the whole instance non-sensical.
What do you guys think?