What do you mean, backwards compatibility?

Preview:

DESCRIPTION

The Java driver for MongoDB has been around almost as long as the NoSQL database itself. It was designed without some of the modern Java features we now take for granted, and the API might be easier with features like lambdas. The existing Java driver is extensively used, which leads to a tricky question: how do you create a new API that uses modern development patterns whilst retaining backwards compatibility? Your users are fundamental to the success of your business, you do not want to alienate them, break their systems or make it hard for them to migrate to the New World Order. In this presentation Trisha will share some of the pain experienced and solutions tried while creating a new Java driver for MongoDB.

Citation preview

Trisha Gee

#GeeCON

Java Driver Developer, 10gen@trisha_gee

What do you mean, backwards compatibility?

Thursday, 16 May 13

Design: translate the requirements in a specification that describes the global architecture and the functionality of the system.

http://homepages.cwi.nl/~paulk/patents/isnot/node4.htmlThursday, 16 May 13

Managing the Development of Large Software Systems - Dr Winston Royce

http://www.cs.umd.edu/class/spring2003/cmsc838p/Process/waterfall.pdf

Thursday, 16 May 13

Agile Design

<This Page Left Intentionally Blank>

Thursday, 16 May 13

Design is a Process, not a Document

Thursday, 16 May 13

What are you saying?

• Design is a journey, enjoy the ride

• There will be Monsters

• There will be Safe Houses

• There might not even be a destination...

Thursday, 16 May 13

Best Job Evar!!

Thursday, 16 May 13

We’re off!Thursday, 16 May 13

Backward CompatibilityThursday, 16 May 13

Lots of unknownsThursday, 16 May 13

Design GoalsThursday, 16 May 13

Yes, it’s a documentThursday, 16 May 13

Design Goals

• Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

Lack of consistencyThursday, 16 May 13

Coding StandardsThursday, 16 May 13

Zero Analysis ErrorsThursday, 16 May 13

No more argumentsThursday, 16 May 13

Design Goals

✓Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

UsersThursday, 16 May 13

Identify Our UsersThursday, 16 May 13

1. Java Developers

2. ODMs / other drivers / third parties

3. Contributors

Three Types Of Users

Thursday, 16 May 13

Java Developers

• Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

•Test friendly

•Backwards compatible

Thursday, 16 May 13

Third Party Libraries

•Consistency

•Cleaner design

• Intuitive API

• Sane Exception handling

•Test friendly

•Backwards compatible

Thursday, 16 May 13

Contributors

•Consistency

•Cleaner design

• Intuitive API

• Sane Exception handling

•Test friendly

• Backwards compatible

Thursday, 16 May 13

Users are our friendsThursday, 16 May 13

Backward CompatibilityThursday, 16 May 13

ArchitectureThursday, 16 May 13

UML, yuk!Thursday, 16 May 13

High Level ArchitectureThursday, 16 May 13

Scala DriverThursday, 16 May 13

Design Goals

• Consistency

✓Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

Design Goals

• Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

•Backwards compatible

Thursday, 16 May 13

High Level ArchitectureThursday, 16 May 13

Option 1: WrappingThursday, 16 May 13

Option 2: ConnectingThursday, 16 May 13

Backward Compatibility?Thursday, 16 May 13

Tests PassThursday, 16 May 13

We win!Thursday, 16 May 13

Design Goals

• Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

✓Backwards compatible

Thursday, 16 May 13

Not Dead Yet...Thursday, 16 May 13

The Public APIThursday, 16 May 13

Design Goals

• Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

Caveats

• It won’t look like this

• Haven’t decided consistent names yet

• Need something that suits all drivers

Thursday, 16 May 13

Find

Thursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

Thursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

collection.find(query).skip(1000).limit(100);

Thursday, 16 May 13

Find

Thursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

collection.find(query).skip(1000).limit(100);

collection.find(query, fields);

Thursday, 16 May 13

Which One?Thursday, 16 May 13

Find

Thursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

collection.find(query).skip(1000).limit(100);

collection.find(query, fields);

Thursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

collection.find(query).skip(1000).limit(100);

collection.find(query, fields);

collection.find(query).select(fields);

Thursday, 16 May 13

Fewer DecisionsThursday, 16 May 13

“Cmd + space” friendlyThursday, 16 May 13

Findcollection.find(query).skip(1000).limit(100);

collection.find(query).skip(1000).limit(100);

collection.find(query, fields);

collection.find(query).select(fields);

Thursday, 16 May 13

Remove

Thursday, 16 May 13

Removecollection.remove(query);

Thursday, 16 May 13

Removecollection.remove(query);

collection.find(query).remove();

Thursday, 16 May 13

Find and Modify

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

collection.find(query).updateOneAndGet(update);

Thursday, 16 May 13

They hate me!Thursday, 16 May 13

Find and Modify

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

collection.find(query) .updateOneAndGet(update);

collection.findAndModify(query, fields, sort, false, update, true, false);

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

collection.find(query) .updateOneAndGet(update);

collection.findAndModify(query, fields, sort, false, update, true, false);

collection.find(query) .sort(sort) .updateOneAndGet(update);

Thursday, 16 May 13

Find and Modify

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

collection.find(query) .updateOneAndGet(update);

collection.findAndModify(query, fields, sort, false, update, true, false);

collection.find(query) .sort(sort) .updateOneAndGet(update);

Thursday, 16 May 13

Find and Modifycollection.findAndModify(query, update);

collection.find(query) .updateOneAndGet(update);

collection.findAndModify(query, fields, sort, false, update, true, false);

collection.find(query) .sort(sort) .updateOneAndGet(update);

collection.find(query) .sort(sort) .getOneAndUpdate(update);

Thursday, 16 May 13

Lack of consistencyThursday, 16 May 13

Consistency at lastcollection.find(query).limit(10);

collection.find(query).limit(10).remove();

collection.find(query).sort(sortCriteria).getOne();

collection.find(query).sort(sortCriteria).remove();

collection.find(query).sort(sortCriteria).count();

Thursday, 16 May 13

Muerto del todo

✓Consistency

• Cleaner design

• Intuitive API

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

Design Goals

• Consistency

• Cleaner design

• Intuitive API...

• Sane Exception handling

• Test friendly

• Backwards compatible

Thursday, 16 May 13

Not Dead Yet!Thursday, 16 May 13

Tutorial/hack sessionThursday, 16 May 13

This talkThursday, 16 May 13

Design is a Process, not a Document

Thursday, 16 May 13

Q & A

Thursday, 16 May 13

1.Are you using the Java driver?

Thursday, 16 May 13

2. What do you like about it?

Thursday, 16 May 13

3. What are your pain points?

Thursday, 16 May 13

Design is a Process, not a Document

Thursday, 16 May 13

Your Questions

Thursday, 16 May 13

Recommended