130 likes | 297 Views
OData Design Principles. July 26, 2012. Build on HTTP, REST. OData is a RESTful HTTP Protocol Build on HTTP Entities modeled as Resources Relationships modeled as links CRUD = POST, GET, PUT/PATCH, DELETE OData is Hypermedia-Driven Service Document Edit Links Relationship Navigation
E N D
OData Design Principles July 26, 2012
Build on HTTP, REST • OData is a RESTful HTTP Protocol • Build on HTTP • Entities modeled as Resources • Relationships modeled as links • CRUD = POST, GET, PUT/PATCH, DELETE • OData is Hypermedia-Driven • Service Document • Edit Links • Relationship Navigation • Actions/Functions in payload • Enables loose coupling between clients and services
Leverage Existing Formats • Build on existing Formats • ATOM, JSON, XML • Leverage built-in functionality appropriate to format where present • ATOM links, ids, etc. • Leverage extensibility for functionality not part of format • Namespaces for control data, conventions
Model Driven • The Model defines the Contract • Defines Entity Sets, Entity Types, Functions • Set of possible valid common requests are derived from the model according to well defined semantics and conventions for querying, updating, and invoking operations • Enabled client query string building • Defines result shapes • Enables codegen of strongly typed objects at design time • Improves semantic interoperability while providing the client the most flexibility in the requesting desired data
Simplicity is Key • Make it easy to implement over a broad variety of data sources • Incremental work for more advanced functionality • Conventions and semantics over a well defined model, common tools and libraries should make it easier to implement than defining a custom RESTful protocol.
Client Focused • Define a simple to consume model that guides the client experience • Relationships rather than Foreign Keys • Inheritance rather than joins or descriminator fields • De-normalize as appropriate
Consistency • Consistency across the interface facilitates understanding and makes it easier to reuse code • Applying common principles makes the interface predictable • Principle of least astonishment • More advanced scenarios should not work differently than simple scenarios
Reach over Rich • Make the common stuff available and simple across services for the greatest number of consumers • Don't try and define every possible feature of every underlying store • i.e., Don't try and implement all of TSQL
Extensible • Support advanced/custom scenarios through Extensibility • Metadata annotations for metadata extensibility • Instance annotations for data extensibility • Functions for query extensibility • Actions for CUD/Operational extensibility • Leverage Format-specific Extensibility • Enable common, shared extensions for features outside of OData's core functionality
Extensions are Well Behaved • Extensions should be “opt-in” • Unless the client does something different, behavior should be as defined in Core • Client libraries should not have to know about extensions to work correctly
Extensions Compose Well • Specific extensions should use common extensions for common concepts • i.e., Analytics extensions should use common vocabularies for units, common display hints, etc.