Hello Joel,

On Apr 18, 2009, at 1:43 , Joel Schuster wrote:

I've done some looking around for some best practice guidelines. Can't find anything other than speaking to standard software methodologies. Not really clear examples.

First of all, I could not resist pasting a link here to a keynote Dan North gave two years ago about "no best practices": http://tinyurl.com/3xn8dw

1. Is it a good idea to separate Interfaces and Implementations into separate bundles. In my case there are a number of possible implementations for certain service interfaces that may come along in time within my development group. If I include the Interface in my first implementation bundle then new implementations of that interface will either have to have a dependency to my first implementation or be included together with the other implementation. Neither of these seem like good ideas. So my thinking is to create a number of small bundles that include only the interface, or one bundle with all the interfaces. However, one of the best practices I did find said something about not creating huge dependency trees.

There are definitely trade-offs you have to make here. You already name most of the issues. One other thing you want to consider is rate of change. If your implementations change way more often than your interfaces, then I would move in the direction of having your interfaces in diffferent bundles than your implementations. Again, then think about if you change individual interfaces or if you change all of them at once. We have used one bundle with all our "domain interfaces" in a couple of OSGi applications and that worked quite well for us.

On the other hand, having less bundles overall, might reduce complexity, so don't make bundles too fine grained. Putting interface and implementation in a bundle together for example does make it easier to distribute, as you might only need to install one bundle instead of 2.

2. What do people do to set up unit tests for their services? JUnit? I started going down the track of creating a test interface that could be queried by a 'testing service'. It would look for all implementations of that testing interface and run all the tests. It then occurred to me that there's got to be something out there that already does something like this. Of course the problem with this way of looking at things is that only the exposed (exported) services/packages could be tested.

We use a custom designed Ant build that has evolved over the last 7 years of using OSGi. Most of the time we setup projects with 3 types of tests: - pure unit tests, that really test one class in isolation and don't even bother running in an OSGi container (we chose TestNG, but JUnit works fine too); - integration tests that run a subset of all bundles in an OSGi framework, with one test bundle containing a set of tests that gets deployed alongside the other bundles, runs the tests and quits the framework again; - UI tests (for Swing applications) that are based on TestNG + FEST/ Swing and run in OSGi too.

Greetings, Marcel


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org

Reply via email to