APIs Flashcards

1
Q

GET

A

Read

http://www.example.com/customers/12345/orders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

PUT

A

Update/Replace

http://www.example.com/customers/12345/orders/98765

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

PATCH

A

Update/Modify

http://www.example.com/customers/12345/orders/98765

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

DELETE

A

Delete

http://www.example.com/customers/12345/orders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

POST

A

Create

http://www.example.com/customers/12345/orders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Principles of Good API Design

A
  • Do one thing and do it well
  • APIs should be as small as possible because it can be difficult to remove features. Conceptual weight is more important than supporting a lot of endpoints. Think about it in terms of power to weight ratio.
  • Don’t let implementation details leak into the API. (e.g.. on disk and serialization formats, tuning parameters.)
  • Maximize information hiding so modules can be built, tested, and debugged separately
  • Choose names carefully and be consistent
  • Re-use requires good design and good documentation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Performance Consequences of Poor API Design

A

Bad

  • Making types mutable
  • Providing a constructor instead of static factory. (Static factories are not required to create a new object every time they are called. Prevents the creation of unnecessary objects.)
  • Using a concrete implementation type instead of an interface
  • Example: Component.getSize() returns a dimension that is mutable. That means each call much create a new Dimension object, which results in millions of needless object allocations.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly