A parent-api-impl project structure is kind of new to me. Our Java maven project structure is like this:
> com.sample.myproject
> com.sample.myproject.api
> com.sample.myproject.impl
My questions would be:
How do I create such project in Eclipse in such a way that they are connected with each other?
When is this kind of structure advisable?
Is there any site or reference that I can refer to, that discusses this kind of structure? A tutorial or a guide perhaps?
I think it might make more sense to answer your questions in reverse order...
Since you have an API, the Facade Data Pattern might be a good point to start. The aim of this pattern is to essentially provide an interface to which external users can connect to.
This type of structure is usually desired when you want to expose a series of functions (an API) without divulging how you actually when about an implemented such functions. So, for instance, you just expose a public BigDecimal calculateTax(BigDecimal amount, double percentage)
to your users, without showing how you went about and implemented your method.
Lastly, this is how I would do it:
com.sample.myproject
will be my core project and in it I will put any core functionalities such as persistence of objects.
com.sample.myproject.api
will be essentially a project with Interfaces
and other things I want to expose.
com.sample.myproject.impl
will implement the two projects above by using the core project and some extra logic to expose what API layer is making available.
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