Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android University Fall 2020 Week 3 / Unit 9

Android University Fall 2020 Week 3 / Unit 9

Marina Tanasyuk

November 14, 2020
Tweet

More Decks by Marina Tanasyuk

Other Decks in Education

Transcript

  1. Hi, I’m Marina ✌ CodePath alumni (2016) Currently @ Instacart

    https://www.linkedin.com/in/marinatanasyuk/
  2. Goals of Unit 9 & Plan for today 1. Design

    your apps data models and networking behavior: • Good API vs Bad API • UI -> API & Network requests 2. Plan your first build sprint: • Why? How?
  3. Good APIs vs bad APIs • Documentation • Meaningful error

    messages • Performance • Authentication • Minimalism • RESTfulness • Consistency
  4. RESTful APIs / services = REpresentational State Transfer REST is

    Resource based (things vs actions). The REST architectural style describes six constraints: • Uniform interface • Stateless • Client - Server • Cacheable • Layered System • Code on demands
  5. Consistency - Request body format not ISO 8601 format (YYYY-MM-DD)

    numeric, but encoded as a String * redundant * mix of Integers and Strings not used, but still sent
  6. Consistency - Response body format all of the sudden it

    is an Integer instead of a String movies are now top-level objects with their ids as keys Boolean, but encoded as a String or Number Inconsistent!
  7. Consistency - Response body format (better way) “movies” is the

    key that contains a list of movie objects encoded as Boolean ISO 8601 format (YYYY-MM-DD) encoded as Number
  8. UI -> API 1. Identify objects in your app 2.

    Identify these objects’ attributes 3. Create data models to represent these objects 4. Identify what kind of actions you'll take on each object
  9. “Timeline”: Objects & Attributes Landing Screen: Feed (a collection of

    objects) Objects: ◦ Story ◦ Author / Friend (Collaborator) = User
  10. “Timeline”: Story model Attribute / Property * Type Description objectId

    String Unique id for the Story object (default value) caption String Caption of the Story image / imageUrl String / File Url of a background image or the Image itself author Pointer to User Author of the Story moments List<Moment> List of User’s moments in the Story collaborators List<User> List of collaborators for the Story createdAt Date Date when Story is created at (default value) updatedAt Date Date when Story is last updated (default value)
  11. “Timeline”: Moment model Attribute / Property Type Description objectId String

    Unique id for the Story object (default value) story Pointer to Story The Story this Moment belongs to caption String Caption of the Moment image / imageUrl String / File Url of a background image or the Image itself comments List<Comment> List of comments in the Moment likesCount Number Number of likes for the Moment createdAt Date Date when Moment is created at (default value) updatedAt Date Date when Moment is last updated (default value)
  12. CRUD operations Action Method Example • Create: POST Create a

    new Story • Read: GET Fetch user’s Stories • Update: PUT Update user’s profile • Delete: DELETE Delete a comment on a Moment
  13. Timeline: Network Requests • Landing screen: ◦ (Read/GET) Query all

    stories where user is author ◦ (Create/POST) Create a new story • Story screen: ◦ (Create/POST) Add a new moment to the story ◦ (Create/POST) Add a new collaborator ◦ (Delete) Delete existing collaborator ◦ (Update/PUT) Update title of a Story • Moment screen: ◦ (Create/POST) Add a new comment ◦ (Delete) Delete existing comment ◦ (Create/POST) Add a new like ◦ (Delete) Delete existing like ◦ (Update/PUT) Update caption of a Moment
  14. Sprint planning • Break the work into sizeable chunks (if

    a story takes more than a week, it should be broken down) • Do not overcommit • Learn your teammates (their interest and work style) • Check in often (ex.: everyday stand up meeting)
  15. Deliverables 1. Updated README with Schema Section: a. Data Models

    b. Networking 2. Sprint Plan using GitHub project management flow: a. Project created b. Milestones created c. Issues created from user stories d. Issues added to project and assigned to specific team members
  16. Thanks! Now go crush it. Material to check out: https://restfulapi.net/

    https://apisyouwonthate.com/blog/put-vs-patch-vs-json-patch https://blog.usejournal.com/how-not-to-design-restful-apis-fb4892d9057a