orientechnologies / orientdb-labs

OrientDB Labs hosts last development version of OrientDB.
Apache License 2.0
17 stars 3 forks source link

[OEP 6] Public-internal API separation on a package level #6

Open taburet opened 8 years ago

taburet commented 8 years ago

Summary:

Separate public and internal classes/interfaces/enums on a package level to achieve a cleaner API. Move everything that is not a part of the public API to internal packages. An internal package is a package which name contains ".internal." infix compared to its public counterpart, if any.

Goals:

Non-Goals:

Success metrics:

Motivation:

It's really hard to understand what is considered public and what is not in the current ODB code base. This is bad. ODB developers may break public things unexpectedly. Developers of the ODB-based solutions may introduce dependencies on things that are considered internal by ODB developers.

Description:

Package-based separation will provide clean indication of a public API. For users, if you don't see "internal" in a package name, it's public, you may use anything from it safely. If you see "internal" in the package name, you still may use anything from it, but at your own risk. Java API documentation should be updated to mention this fact.

For ODB contributors, if you see "internal" in a package name, you may change anything without a fear of breaking things. If you don't see "internal", be careful while changing something, it's a public API. Think twice before removing, changing or deprecating something, think triple before adding something new, we have to support it.

For each Java file in the ODB code base following steps should be taken:

  1. Decide is it public or not.
  2. If it's public, skip it.
  3. Create a new internal package to host it, if package doesn't exist.
  4. Move it to the new package.

For consistency, we must choose only one internal package naming scheme:

  1. $project.$module.internal.$subpackage: com.orientechnologies.orient.etl.internal.source, com.orientechnologies.orient.core.internal.command.script, com.orientechnologies.lucene.internal.
  2. $project.$module.$subpackage.internal: com.orientechnologies.orient.etl.source.internal, com.orientechnologies.orient.core.command.script.internal, com.orientechnologies.lucene.internal.
  3. $project.internal.$module.$subpackage: com.orientechnologies.orient.internal.etl.source, com.orientechnologies.orient.internal.core.command.script, com.orientechnologies.internal.lucene.

Alternatives:

Risks and assumptions:

Impact matrix

andrii0lomakin commented 8 years ago

Just come to my mind. We can easily migrate to JDK 9 modules after such refactoring and support OSGi modules.

andrii0lomakin commented 8 years ago

Also, +1 for the third approach. The structure of our modules is too fuzzy.

tglman commented 8 years ago

yes agree on the convention, i've no preferences on the actual format, so please just choose one, in any case with the new API( OEP 2,3,5 ) will be much more hard for user interact with internal api, and will be more clear for us as well what is public because it need to be declared on some specific interfaces.

tglman commented 7 years ago

Hi,

Another thing i was thinking on this topic, as soon as all the refactor of the API is done we could move the public api to an "orientdb-api" project, and the client and core(embedded) will depends on it, this will make really clear what is public what is not, and make possible to have a client independent to the core, so no need to change the packages to internal.

WDYT?

taburet commented 7 years ago

@tglman good idea, it's a good practice, I think, to define a public API in terms of interfaces and place them into a separate "module".

tglman commented 7 years ago

I'm not sure in which release we can get this completely done, but i'll start to work on that direction an all the refactors i'm working on, so i we agree with the module solution we can declare this OEP done and close it.

andrii0lomakin commented 7 years ago

@tglman wait guys we close ? Is it already implemented ?