Introduction to API Design: REST and Java

Post on 06-Dec-2014

2.089 views 7 download

Tags:

description

An introduction to application programming interfaces.

Transcript of Introduction to API Design: REST and Java

(1)

Introduction to API Design:REST and Java

Philip Johnson

Collaborative Software Development Laboratory

Information and Computer Sciences

University of Hawaii

(2)

What is an API?

Specifies a boundary between 2 systems•What you can do•What you can't do

The boundary is defined by:•Functions you can invoke•Objects passed & returned

APIs can exist:•Within a single program•Between independent programs

(3)

Advantages of APIs

Simplifies design by creating partitions Enables change without "ripple effect" Enables multiple implementations Enables development to scale•Larger development teams•Concurrent development

(4)

Disadvantages of APIs

Increases implementation complexity Creates boundaries that can make certain changes hard to accomplish

Can impede performance optimization

(5)

Kinds of APIs

Within a program•Separates components.•Creates "public" and "private" areas.

Between programs•Specifies a "protocol"•How to send and receive information.

(6)

Example in-Program API: Java Collections Framework

Interface java.util.Collection•boolean add (Object o)•void clear()•boolean equals(Object o)•boolean isEmpty()

This API is implemented by:•HashSet, LinkedList, TreeSet, etc.

(7)

(8)

Example between-program (REST)API: Twitter

The Twitter API is a RESTful protocol:

http://api.twitter.com/version/statuses/public_timeline.format•Operations: GET•Formats: json, xml, rss, atom•Authentication: none•Parameters: trim_user, include_entities

(9)

(10)

Example between-program (REST)API: WattDepot

(11)

The Solar Decathlon iHale System

(12)

The Solar Decathlon iHale System

Within-program between-program

(13)

On to the demo