53
2012 Nov 29, christophercotton.com API Design & Junior Senior Christopher Cotton @_cotton for @NashSoftware

API Design & Moving from Junior to Senior Developer

Embed Size (px)

DESCRIPTION

Talk given for @NashSoftware about API Design (How to consume, How to create). And, the process of moving from a Junior to a Senior Developer.

Citation preview

Page 1: API Design & Moving from Junior to Senior Developer

2012 Nov 29, christophercotton.com

API Design&Junior ➪ SeniorChristopher Cotton @_cotton for @NashSoftware

Page 2: API Design & Moving from Junior to Senior Developer

The Past

✤ 20+ years Programming

✤ Been QA Tester, Junior Dev, Senior Dev, Technical Lead, Project Lead, Architect, Senior Member of Technical Staff 3 (What?!), CTO, Founder, Consultant and lots of random other jobs

✤ javax.mail http://www.google.com/#q=javax.mail+cotton

Page 3: API Design & Moving from Junior to Senior Developer

The Now

✤ iOS, Android, Ruby on Rails

✤ @NashGameDev

✤ @SpacewardHo

✤ http://handstand.io

✤ Teach Kids Programming (YSI) http://www.fssd.org/index.php?option=com_content&task=view&id=110&Itemid=207

Page 4: API Design & Moving from Junior to Senior Developer

Date

My Version, Not “The Truth”

Page 5: API Design & Moving from Junior to Senior Developer

API stands for?

Page 6: API Design & Moving from Junior to Senior Developer

This does what?

User.find_or_create_by_name("Bob")

Page 7: API Design & Moving from Junior to Senior Developer
Page 8: API Design & Moving from Junior to Senior Developer

API

✤ Contract - documented, agreement, cause/effect

✤ Interface - one service to another

✤ GEM, Library, TCP, HTTP, etc.

✤ Systems Integration

Page 9: API Design & Moving from Junior to Senior Developer

Date

Lonely App

Page 10: API Design & Moving from Junior to Senior Developer

Date

API Here, API There, Everywhere

Page 11: API Design & Moving from Junior to Senior Developer

Date

Current Architecture

Device App

ContentDBScraper Packager FileStorage

Content Server

Blogs/Websites

App.Handstand

Google Analytics Task

Builder

Customer

Builder

Article List

Article Package

Amazon SQS

Market TaskAndroid Market

Config

LogAd List

Ads

AmazonS3

Version 2010/12/31All rights reserved

Handstand

Internal Systems

Page 12: API Design & Moving from Junior to Senior Developer

Date

API - How to Consume

Page 13: API Design & Moving from Junior to Senior Developer

How to use? What would you do?

Page 14: API Design & Moving from Junior to Senior Developer
Page 15: API Design & Moving from Junior to Senior Developer
Page 16: API Design & Moving from Junior to Senior Developer
Page 17: API Design & Moving from Junior to Senior Developer
Page 18: API Design & Moving from Junior to Senior Developer
Page 19: API Design & Moving from Junior to Senior Developer
Page 20: API Design & Moving from Junior to Senior Developer

Date

API - How to Design

Page 21: API Design & Moving from Junior to Senior Developer

Lots of Other Resources

✤ How to design RESTful APIs

✤ CRUD

✤ HTTP API

Page 22: API Design & Moving from Junior to Senior Developer

What is the point?

Page 23: API Design & Moving from Junior to Senior Developer

Who will use it?

✤ Dell Digital Delivery - 10 million machines, more each year to download software

✤ Cyberdog - other developers to implement new components

✤ JavaSoft javax.mail - Developers implementing Services, or sending Email

✤ Handstand - devices retrieving travel magazine

Page 24: API Design & Moving from Junior to Senior Developer

Date

Document, Document, Document

Page 25: API Design & Moving from Junior to Senior Developer

Why Document?

✤ Another programmer will need to know how it works, and trial and error sucks

✤ Test Your API, write a client from your own docs

✤ Keeps your code honest

✤ Becomes a real API when a client is written by someone other than you from your docs

Page 26: API Design & Moving from Junior to Senior Developer

3ULPHU�Y��$3,�6SHFLILFDWLRQ���������� Y�����

&UHDWH�8VHU5(48(67��$XWKHQWLFDWLRQ�QRW�UHTXLUHG�

�3267��DSL�Y��FUHDWHBXVHU

�3$5$0(7(56�

XVHU>HPDLO@ 8VHU¶V�HPDLO� UHTXLUHG

XVHU>SDVVZRUG@ 8VHUV�SDVVZRUG� UHTXLUHG

XVHU>ILUVWBQDPH@ 8VHUV�ILUVW�QDPH� UHTXLUHG

XVHU>ODVWBQDPH@ 8VHUV�ODVW�QDPH� UHTXLUHG

�5(63216(��6HW�&RRNLH�KHDGHU�DQG�-621�SD\ORDG�

�+773���������2.�&RQWHQW�7\SH��DSSOLFDWLRQ�MVRQ��FKDUVHW XWI��6HW�&RRNLH��8 ^XVHUBXLG`��SDWK ���H[SLUHV 6DW�����$XJ���������������*076HW�&RRNLH��7 ^DXWKBWRNHQ`��SDWK ���H[SLUHV 6DW�����$XJ���������������*07�^�����FRGH��������������PVJ����2.�������GDWD���^���������ILUVWBQDPH����^ILUVWBQDPH`�����������ODVWBQDPH����^ODVWBQDPH`�����������XVHUBXLG����^XVHUBXLG`�����``��

(55256�

0HVVDJH���PVJ�� 'HVFULSWLRQ

�HPDLO�PLVVLQJ� 7KH�HPDLO�SDUDPHWHU�ZDV�PLVVLQJ

+DQGVWDQG�&RQILGHQWLDO ��

Page 27: API Design & Moving from Junior to Senior Developer

Find & Reuse Good APIs

✤ Don’t reinvent the wheel

✤ Find another similar, and expand or convert

✤ Learn from bad APIs

Page 28: API Design & Moving from Junior to Senior Developer
Page 29: API Design & Moving from Junior to Senior Developer

Key Aspects

✤ Versioned

✤ Errors - was the request successful? invalid data? server blew up?

✤ Consistent to itself - delete_book, friend_delete

✤ Iteration

✤ Design with a partner or isolation, not large groups

Page 30: API Design & Moving from Junior to Senior Developer

Iteration

✤ High Level APIs

✤ Data Model, Design Objects and Connections

✤ Keep asking, what other actions need to be done? What other data?

✤ Walk through the scenarios

✤ retrieve library, log in, add book, delete book, post comment

Page 31: API Design & Moving from Junior to Senior Developer
Page 32: API Design & Moving from Junior to Senior Developer
Page 33: API Design & Moving from Junior to Senior Developer

Date

Practice, practice, practice

Page 34: API Design & Moving from Junior to Senior Developer

Date

Q & A, Part One

Page 35: API Design & Moving from Junior to Senior Developer

Date

SeniorJunior ➪

Page 36: API Design & Moving from Junior to Senior Developer

✤ Worried about how you look, or what you say

✤ Focused on small parts, misses big picture

✤ Makes changes without understanding repercussions

✤ Not my part

Characteristics of Bad Junior(or bad Senior)

Page 37: API Design & Moving from Junior to Senior Developer

Good Senior Developer(or Good Junior Developer)✤ Says, “I don’t know”

✤ Takes responsibility

✤ Continually Learning

✤ Will “Take one for the team”

✤ Given Any Problem, Can Invent a solution

✤ Can learn needed skills

✤ Goes beyond the basics

Page 38: API Design & Moving from Junior to Senior Developer

Basic Mistakes

Page 39: API Design & Moving from Junior to Senior Developer

Separate Concerns of Code

✤ Putting code unrelated into one group/class

✤ Networking code in the DB code

✤ UI Controller Code, with Table Cell Display Code

✤ Too many lines!

✤ “Wasn’t sure where else to put it” Ask!

Page 40: API Design & Moving from Junior to Senior Developer

Cut & Paste Solutions

✤ Found something on Stack Overflow, paste it in!

✤ The Interweb is not always correct

✤ Take the time to understand what it does, and why

Page 41: API Design & Moving from Junior to Senior Developer

Hard Coded Values

✤ Just don’t do it. Use config, use Class definitions, or Statics

Page 42: API Design & Moving from Junior to Senior Developer

Reinvention, Bad idea

✤ Calendar formatter

✤ Network Library

✤ Search, or ask. Know your domain

Page 43: API Design & Moving from Junior to Senior Developer

Warnings, Errors

✤ Fix warning messages, they are usually there for a reason

✤ If something fails, understand WHY it failed. Interested in making sure it doesn’t happen again

✤ Know where to fix it, document your changes

✤ Example: Cucumber test with TEXTAREA gave an extra ‘\r’

Page 44: API Design & Moving from Junior to Senior Developer

Be sure to test

✤ “I’m sure it must work in all those cases”

✤ Take the time to think about your code

Page 45: API Design & Moving from Junior to Senior Developer

Too Focused on Small Parts

✤ Focus on the most important parts. Don’t know? Ask!

✤ iOS app, focused on getting a particular toolbar exact to the specifications, but those specifications would change

✤ Optimizing before recording data, profiling

Page 46: API Design & Moving from Junior to Senior Developer

How will this change the app?

✤ DB code, using “select statements” and adding in specific fields

✤ Made it work in the short term, impossible to manage in the long term

✤ Change one class, but not really understand how it is used elsewhere

Page 47: API Design & Moving from Junior to Senior Developer

Date

How to Improve

Page 48: API Design & Moving from Junior to Senior Developer

Date

Mentoring

Page 49: API Design & Moving from Junior to Senior Developer

Date

Ask for Feedback, Code Reviews

Page 50: API Design & Moving from Junior to Senior Developer

Date

Read/Learn

Page 51: API Design & Moving from Junior to Senior Developer

Date

Build Tools, APIs, LibrariesDon’t do the same thing over and over

Page 52: API Design & Moving from Junior to Senior Developer

Date

Enjoy the process

Page 53: API Design & Moving from Junior to Senior Developer

Date

What is your.... Q & A, Part Deux