Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java API Design - Internal Design

Tags:

java

api

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
like image 743
Kyle Kroboth Avatar asked Apr 25 '12 20:04

Kyle Kroboth


1 Answers

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

like image 161
Ferenc Mihaly Avatar answered Sep 22 '22 06:09

Ferenc Mihaly