[JAVA-303] Convert Mongo/DB/DBCollection to interfaces Created: 22/Mar/11 Updated: 06/Apr/23 Resolved: 27/Mar/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Scott Hernandez (Inactive) | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 11 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Major Change | ||||||||||||
| Description |
|
There are many testing/mock frameworks which prefer to work with interfaces rather than (abstract) classes. |
| Comments |
| Comment by Jeffrey Yemin [ 27/Mar/14 ] |
|
After much discussion, we've decided not to make this change. I apologize to those who have been waiting for it for a long time, but binary compatibility is extremely important to us and we're not going to make a change like this that breaks it. Instead, we will develop an entirely new API for database/collection/cursor that is defined using interfaces from the start. Users who need interfaces can migrate to the new API. |
| Comment by Jeffrey Yemin [ 03/Sep/13 ] |
|
@Christian, we are exploring design alternatives here. Can you tell me what would be the implication for your software stack if the driver uses interfaces for DB/DBCollection, and were to add methods to those interfaces in minor releases (which would be quite likely)? |
| Comment by Christian Tonhäuser [ 03/Sep/13 ] |
|
Is this going to happen in 3.0.0? |
| Comment by Jeffrey Yemin [ 14/Feb/13 ] |
|
This is not going to happen until 3.0, as it will break binary compatibility. |
| Comment by Christian Tonhäuser [ 14/Feb/13 ] |
|
I'd also like to have things like DB, DBCollection, DBCursor, ... being Interfaces. For now we built delegates, but that's a rather big pain. |
| Comment by Jeffrey Yemin [ 30/Nov/12 ] |
|
Had to close and re-open to get the resolution out of the wrong state. |
| Comment by Rick Curtis [ 28/Nov/12 ] |
|
Can someone change the resolution to something other than 'fixed'? That blocks people from voting. |
| Comment by Rick Curtis [ 28/Nov/12 ] |
|
Any chance that this is going to get completed in the next release? |
| Comment by Andrew Duncan [ 04/Sep/12 ] |
|
I tried to vote for it, but I don't seem to have permission This is a thin DAO layer I'm trying to implement, my "domain model" is essentially a series of maps. I can hold on for version 3, though. |
| Comment by Jeffrey Yemin [ 03/Sep/12 ] |
|
It has 0 votes, for one... For now, can you mock at the the DAO layer of your application instead? We'll likely do this in a major release (3.0), as it will break binary compatibility. |
| Comment by Andrew Duncan [ 03/Sep/12 ] |
|
Hi. Whatever happened to this change? Trying to efficiently mock DBCollection is killing me. Thanks. |
| Comment by Bernardo S. A. Silva [ 09/Apr/11 ] |
|
Recreate the PATCH from the 2.5.3 version. |
| Comment by Bernardo S. A. Silva [ 08/Apr/11 ] |
|
Because that leads to more code change. I extracted the Interface like I said (MongoInterface) and now Mongo implements it. So, with that, you can already mock. The only problem is that there is a lot of places (and backward compatibility) that says: Mongo mongo = new Mongo(...); But DB and DBCollection are interfaces now, and the abstract classes was renamed to DBImpl and DBCollectionImpl. I tested all combinations and I think that one is by far that keeps backward compatibility. By the way, mocking works perfectly. I tested with Mockito and PowerMock. |
| Comment by Remon van Vliet [ 07/Apr/11 ] |
|
Why wasn't Mongo converted to an interface like the rest? This still means you'd have to refactor mongo related code in your applications to use MongoInterface rather than Mongo. Not completely insurmountable but certainly not ideal to require a production code refactor to enable mongo mocking. |
| Comment by Bernardo S. A. Silva [ 23/Mar/11 ] |
|
Big refactoring, but simple and easy. |