canonical modeling for api interoperability

35
Canonical Modeling for API Interoperability QCON NEW YORK, JUNE 2014 TED EPSTEIN, FOUNDER AND CEO MODELSOLV, INC. 1 COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Upload: ted-epstein

Post on 27-Jan-2015

119 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Canonical Modeling for API Interoperability

Canonical Modeling for API InteroperabilityQCON NEW YORK, JUNE 2014

TED EPSTEIN, FOUNDER AND CEO

MODELSOLV, INC.

1COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 2: Canonical Modeling for API Interoperability

Overview

• How APIs help developers, how they don’t

• Canonical models: promises and challenges

• Tackling variability in message representations

• A Better Client Library

• Demo and walkthrough

2COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 3: Canonical Modeling for API Interoperability

Developers in the API Jungle

3COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 4: Canonical Modeling for API Interoperability

Services Built in isolation• Many services built to

service a single application or org unit.

• No data or API governance, no shared data models.

• No meaningful guidelines. “Just use schema.”

• No easy path to eventual integration or promotion to shared services.

4COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 5: Canonical Modeling for API Interoperability

Heavy Burden on Developers

5COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 6: Canonical Modeling for API Interoperability

Heavy Burden on Developers• Find the right

service

6COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 7: Canonical Modeling for API Interoperability

Heavy Burden on Developers• Find the right

service

• Negotiate data formats

7COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 8: Canonical Modeling for API Interoperability

Heavy Burden on Developers• Find the right

service

• Negotiate data formats

• Point-to-point integrations:each one is different

8COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 9: Canonical Modeling for API Interoperability

Strained Ecosystem• Bloated code

9COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 10: Canonical Modeling for API Interoperability

Strained Ecosystem• Bloated code

• Memory footprint

10COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 11: Canonical Modeling for API Interoperability

Strained Ecosystem• Bloated code

• Memory footprint

• High integration costs

11COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 12: Canonical Modeling for API Interoperability

Strained Ecosystem• Bloated code

• Memory footprint

• High integration costs

• Slow delivery

12COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 13: Canonical Modeling for API Interoperability

Canonical Models: Promises and Challenges

13COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 14: Canonical Modeling for API Interoperability

A Modest Proposal• Define a common model for

all data communicated between systems.

• Common recommendation in one form or another◦ Patterns of Enterprise Integration

(Fowler)

◦ SOA Design Patterns (Erl)

14COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 15: Canonical Modeling for API Interoperability

Different Uses for Canonical Data Models:API Design◦ SOA Governance: Enforce

consistency with the canonical model (“canonical schema”)

◦ Tools: Compose message formats from canonical data models

SDK Development◦ Abstract physical format◦ Optimize for performance and/or

developer productivity

Integration◦ Transform messages to/from

canonical format.◦ Boundary translation to/from

industry standards

Analysis◦ Analyzing data landscape, service

landscape◦ Compliance, internal audit, MDM,

large-scale integration efforts.

15COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 16: Canonical Modeling for API Interoperability

Why is this so hard?Intrinsic Challenges◦ Getting everyone to the table, getting to

agreement◦ Versioning, Change impact analysis, and

lifecycle management

Economic Alignment Challenges◦ Service developers need to get it done◦ Code-first frameworks promise low-cost

to service developers

Modeling Mismatch: Viewpoint◦ What's the purpose of the model?◦ What level of abstraction? What level of

detail?◦ How does it related to concrete

representations?

Modeling Mismatch: Language and Method◦ ER, UML, OWL, etc.◦ The attractive nuisance of XML Schema

Result: confusion about what the canonical model is supposed to be.

16COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 17: Canonical Modeling for API Interoperability

The Pervasive Problem: Variability • One size fits none

• Message representations vary by◦ Level of detail

◦ Perspective

◦ Topology, Granularity

◦Contextual constraints

◦Metadata

17COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 18: Canonical Modeling for API Interoperability

Realization: Decoupling Models and Messages

18COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 19: Canonical Modeling for API Interoperability

Another Look at the Variability Problem• There’s a common theme

(canon) underneath these variations.

• Can we describe the theme and variations separately?

• Can we model the variations as adaptations, augmentations of the theme?

• There’s a name for that: Realization.

19COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 20: Canonical Modeling for API Interoperability

Realization: Property Subset

20COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

API requests or responses may only need a subset of properties defined in the canonical model.

Realization model may specify a list of included properties.

Page 21: Canonical Modeling for API Interoperability

Realization: Perspective

21COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Message and resource structures project different views from the same logical data model

Canonical model should support bi-directional references.

Realization model should allow embedded or linked representations.

Page 22: Canonical Modeling for API Interoperability

Realization: Metadata

22COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Business Information Model

Account ID

Balance

Margin

Status

Account

Party ID

Name

Party1

0..n

Data Aspects

· Deltas

· Data Source

· Data Security

· Explicit Null Values

...

Message Structure

<party dataSource=“MSDB”>

<partyId>123</partyId>

<partyName xsi:nil=“true” nullValue=“Not Available” />

<accounts>

<account dataSource=“A2” transType=“insert”>

<accountId>XYZ</accountId>

<balance xsi:nil=“true” isRestricted=“true” />

</account>

</accounts>

</party>

APIs may need to augment essential data with descriptive metadata.

Data aspects are cross-cutting concerns that may be woven together with canonical data as part of the interface realization.

Page 23: Canonical Modeling for API Interoperability

Realization: Contextual Constraints

<=$10MMAsset

Class = Bond

23COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

TradeServices may have specific constraints that are not intrinsic to the data definitions.

Realization model may specify constraints on requests or responses. Constraints may take different forms: range, subtype, logical expression, etc.

Page 24: Canonical Modeling for API Interoperability

Canonical Modeling Reloaded• New understanding of the model vs. message:

• Canonical data models describe business information at the conceptual level◦ Semantically rich◦ Technology independent

• Realization models afford variability, with clear limits◦ Bend the canonical model, don’t break it◦ Realized representations must be recognizable as instances of the canonical model.

• Some new terms:◦ Interface Data Model: A realization model used to define data exchanged through an API.◦ Resource Data Model: An interface data model for a RESTful (resource-oriented) API.

24COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 25: Canonical Modeling for API Interoperability

A Better Client Library

25COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 26: Canonical Modeling for API Interoperability

Today’sClient Library

26COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 27: Canonical Modeling for API Interoperability

How many ways from Sunday does this suck?

1. Canonical data model gets lost in the translation.

2. Awkward structures introduced by message format.

3. Annotations are specific to a single API, message format.

4. Not usable as business objects

5. Extra code to populate these DTOs, move data between them and internal representations.

6. High memory footprint

27COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Just say noto DTO.

Page 28: Canonical Modeling for API Interoperability

CanonicalSerializer

No DTOs, no need to code transformations

Single object graphserialized to multiple RDMs, message formats.

Canonical classes/interfaces can be used as business objects.

Flexibility: pluggable formats for canonicalmodel, RDM, object graph and media type.

28COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 29: Canonical Modeling for API Interoperability

Canonical Serializer: ImplementationWhat do we call a serializer that

shoots representations out of a canon?

Kaboom Serializer!https://github.com/modelsolv/Kaboom

(Just a demo now, but feedback & contributions welcome.)

29COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 30: Canonical Modeling for API Interoperability

Scenario• TaxBlaster: new tax preparation app.

• Integrates with e-filing service

• Integrates with client billing service

• Common data model, different views

30COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 31: Canonical Modeling for API Interoperability

TaxBlaster: Canonical Data Model

31COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

filingID : stringjurisdiction : stringcurrency : stringyear : dateperiod : intgrossIncome : decimaltaxLiability : decimal

TaxFiling

taxpayerID : stringlastName : stringfirstName : stringotherNames : string*

Person

street 1 : stringstreet2: stringcity : stringstateOrProvince : stringpostalCode : string

Address

companyID : stringcompanyName : stringEIN : stringform : stringactive : boolean

Company

employees

employer 0..1

0..*

taxpayer

1..1

0..*

addresses

Page 32: Canonical Modeling for API Interoperability

Internal Metamodel

Pluggable implementations:

• CDM

• RDM

• Canonical Object Reader/Writer

• Serializer

32COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

name : string

CanonicalDataType

type : primitiveDataType

CDMPrimitivePropertyCDMReferenceProperty

name : stringcardinality : Cardinality

CDMProperty

properties0..*

inverseProperty

targetDataType

name : string

ResourceDataModel

type : primitiveDataType

RDMPrimitivePropertyRDMReferenceProperty

name : stringcardinality : Cardinality

RDMProperty

includedProperties0..*

linkRelation : string

ReferenceLinkReferenceEmbed

embeddedDataModel

Page 33: Canonical Modeling for API Interoperability

Recipe for a model-oriented API client◦A canonical modeling language

◦Data available at runtime that conforms to the canonical model

◦An API description facility that◦ Realizes the canonical model as an Interface Data Model

◦ Described as formalized variations

◦A runtime serializer/deserializer that◦ Interprets the API model

◦ Serializes and deserializes between the the canonical object graph and the the realized message format.

33COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 34: Canonical Modeling for API Interoperability

ConclusionCanonical models are a way to capture organizational agreement on data definitions

We need the right degree of coupling between the canonical model and API representations.

We do this by identifying the kinds of variations that we need to support, and formalizing these in a realization mapping.

Tooling can support realization modeling and apply it in client libraries, SDKs, middleware, etc.

Potential benefits: better interoperability, lower integration cost, higher developer productivity.

34COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.

Page 35: Canonical Modeling for API Interoperability

QuestionsTHANK YOU!

35COPYRIGHT © 2014, MODELSOLV, INC. | ALL RIGHTS RESERVED.