The New Java Driver

Post on 24-May-2015

74 views 6 download

Tags:

description

Trisha Gee gives a rough guide to the new java driver for MongoDB

Transcript of The New Java Driver

Trisha Gee

@trisha_gee

The New Java Driver

Java Developer @ 10gen

Introduction

DISCLAIMER

What’s the point then?

Design Goals

Cleaner designIntuitive APIConsistencySane Exception handlingTest friendlyBackwards compatible

••••••

Design Goals

And async?

Tell me about it...

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

Cleaner Design

So What?

Legacy Applications

Your Java Application

Morphia & ODMs

Other drivers

Wasn’t that just the firstpoint?

Intuitive API - Find

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

collection.filter(query).skip(1000).limit(100).all();

Intuitive API - Remove

collection.remove(query);

collection.filter(query).remove();

Intuitive API - Find and Modify

collection.findAndModify(query, update);

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

collection.filter(query) .sort(sort) .modifyAndGet(update, Get.AfterChangeApplied);

Intuitive API

public interface MongoCollection<T>

Aided by the clean designAids the intuitive APIEnforced by coding standards

•••

Consistency

Consistency

collection.filter(query).limit(10).all();

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

collection.filter(query).sort(sortCriteria).one();

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

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

Document result1 = collection.filter(query) .sort(sortCriteria) .removeAndGet();

Document result2 = collection.filter(query) .sort(sortCriteria) .modifyAndGet(update,AfterChangeApplied);

Client ExceptionsServer ExceptionsNo more parsing error Strings

•••

Sane Exception Handling

Interfaces!Acceptance, functional and unit tests

••

Test Friendly

Very important!•

Backwards compatible

DocumentationSelf documenting codeUnit and Acceptance TestsJavaDocTutorialsBlogs

••••••

And...

In Summary

Cleaner designIntuitive APIConsistencySane Exception handlingTest friendlyBackwards compatible

••••••

In Summary

Questions?

@trisha_gee