I'm making my first API that gets data and parses it from websites. So there is a lot of network and parsing in it. I read about API's having an internal packages in which shouldn't be public; like in Javadocs. So my question is what should and shouldn't be put in the internal package. Here is my package design, I'm leaving out the non important ones.
.networkstats
.networkstats.model
.networkstats.parser
Inside networkstats
package there is a class called NetworkStats
. That is the main class that handles and retrieves all of the network connections. It then uses the classes inside the parser
package to process the data. After it returns a Model class that holds the data inside the model
package. I want to include the internal package because there will be some classes and interfaces that aren't meant to be used by the users.
For example I want to make a class the handles all of the network connections so the other classes like NetworkStats
can access it. Reason I want to do that is because I don't want to copy the code in other classes when It can be in one place. Of course I don't want other users using this class so I would put it in the internal package? I would also put my parser
package in the internal one too. So my main question is that do you put classes and interfaces that aren't meant to be used in the public in the internal package? I know they can still access it.
.networkStats.internal.DataManager // class that handles network connections
.networkStats.internal.parser
You might find this Java API design checklist helpful. The first section is about package design.
http://theamiableapi.com/2012/01/16/java-api-design-checklist/
Ferenc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With