The New Java Driver

38
Trisha Gee @trisha_gee The New Java Driver Java Developer @ 10gen

description

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

Transcript of The New Java Driver

Page 1: The New Java Driver

Trisha Gee

@trisha_gee

The New Java Driver

Java Developer @ 10gen

Page 2: The New Java Driver

Introduction

Page 3: The New Java Driver

DISCLAIMER

Page 4: The New Java Driver

What’s the point then?

Page 5: The New Java Driver

Design Goals

Page 6: The New Java Driver

Cleaner designIntuitive APIConsistencySane Exception handlingTest friendlyBackwards compatible

••••••

Design Goals

Page 7: The New Java Driver

And async?

Page 8: The New Java Driver

Tell me about it...

Page 9: The New Java Driver

Cleaner Design

Page 10: The New Java Driver

Cleaner Design

Page 11: The New Java Driver

Cleaner Design

Page 12: The New Java Driver

Cleaner Design

Page 13: The New Java Driver

Cleaner Design

Page 14: The New Java Driver

Cleaner Design

Page 15: The New Java Driver

Cleaner Design

Page 16: The New Java Driver

Cleaner Design

Page 17: The New Java Driver

Cleaner Design

Page 18: The New Java Driver

Cleaner Design

Page 19: The New Java Driver

Cleaner Design

Page 20: The New Java Driver

So What?

Page 21: The New Java Driver

Legacy Applications

Page 22: The New Java Driver

Your Java Application

Page 23: The New Java Driver

Morphia & ODMs

Page 24: The New Java Driver

Other drivers

Page 25: The New Java Driver

Wasn’t that just the firstpoint?

Page 26: The New Java Driver

Intuitive API - Find

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

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

Page 27: The New Java Driver

Intuitive API - Remove

collection.remove(query);

collection.filter(query).remove();

Page 28: The New Java Driver

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);

Page 29: The New Java Driver

Intuitive API

public interface MongoCollection<T>

Page 30: The New Java Driver

Aided by the clean designAids the intuitive APIEnforced by coding standards

•••

Consistency

Page 31: The New Java Driver

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);

Page 32: The New Java Driver

Client ExceptionsServer ExceptionsNo more parsing error Strings

•••

Sane Exception Handling

Page 33: The New Java Driver

Interfaces!Acceptance, functional and unit tests

••

Test Friendly

Page 34: The New Java Driver

Very important!•

Backwards compatible

Page 35: The New Java Driver

DocumentationSelf documenting codeUnit and Acceptance TestsJavaDocTutorialsBlogs

••••••

And...

Page 36: The New Java Driver

In Summary

Page 37: The New Java Driver

Cleaner designIntuitive APIConsistencySane Exception handlingTest friendlyBackwards compatible

••••••

In Summary

Page 38: The New Java Driver

Questions?

@trisha_gee