tips & tricks of effective - chariot solutionschariotsolutions.com/wp-content/uploads/... ·...

162
Tips & Tricks of Effective iOS Developers

Upload: others

Post on 12-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Tips & Tricks of

Effective iOS Developers

Page 2: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

BEN SCHEIRMAN @subdigital

Page 3: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 4: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Weekly Screencasts on iOS DEVELOPMENT

$9/month

Page 5: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Tips & Tricks of

Effective iOS Developers

Page 6: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

?

Effective

Page 7: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

effective |iˈfektiv| adjective !

successful in producing a desired or intended result

Page 8: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSEffective

Page 9: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSFIX PROBLEMS

Effective

Page 10: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSWRITE CODE FASTER

Effective

Page 11: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSCONFIDENTLY REFACTOR

Effective

Page 12: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSWRITE BETTER CODE

Effective

Page 13: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSWRITE FEWER BUGS

Effective

Page 14: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSGET THINGS DONE

Effective

Page 15: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

!

DEVELOPERSSHIP BETTER SOFTWARE

Effective

Page 16: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

SHIP BETTER SOFTWARE

Page 17: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

ME?

Page 18: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 19: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

I aspire to beEffective

Page 20: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Objective-C Tips

Page 21: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Always use braces for conditionals

if ([self isHungry]) {

[self eatBurger];

}

if ([self isHungry])

[self eatBurger];

if ([self isHungry])

[self eatBurger];

[self takeNap];

if ([self isHungry]) {

[self eatBurger];

[self takeNap];

}

Page 22: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)

goto fail;

if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)

goto fail;

goto fail;

if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)

goto fail;

...

!fail:

SSLFreeBuffer(&signedHashes);

SSLFreeBuffer(&hashCtx);

return err;

Always use braces for conditionals

Page 23: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 24: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

@interface Player

!- (void)moveLeft;

- (void)moveRight;

- (void)jump;

- (void)hit;

!@end

Use Class Continuations for Private Properties

@interface Player ()

@property CGFloat health;

@property Texture *texture;

@end

!@implementation Player

@end

Player.h Player.m

Page 25: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use Class Continuations for Private Properties

@interface ViewController ()

@property IBOutlet UILabel *label;

@end

!@implementation ViewController

@end

Page 26: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use intention revealing method names

- (NSDate *)nextDate:(NSDate *);

- (NSDate *)nextBillingDateAfterDate:(NSDate *);

Page 27: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Name single parameter BOOL arguments

-(void)showPanel:(BOOL)animated;

[self showPanel:NO];

Page 28: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Name single parameter BOOL arguments

-(void)showPanelAnimated:(BOOL)animated;

[self showPanelAnimated:NO];

Page 29: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Add Comment Documentation to Public Methods

Page 30: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

- (void)viewDidLoad {

[self.fetchedResultsController performFetch:nil];

}

Lazily Initialize Properties

- (NSFetchedResultsController *)fetchedResultsController {

if (_frc == nil) {

_frc = [[NSFetchedResultsController alloc]

initWithFetchRequest: self.fetchRequest

...

]

}

! return _frc;

}

Page 31: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Lazily Initialize Properties

- (NSFetchRequest *)fetchRequest {

if (_fetchRequest == nil) {

_fetchRequest = …

}

return _fetchRequest;

}

Page 32: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Lazily Initialize Properties

- (void)didReceiveMemoryWarning {

self.fetchResultsController = nil;

self.fetchRequest = nil;

}

Page 33: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use Refactor Method judiciously- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)

indexPath {

UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@“cell”];

NSArray *peopleInSection = self.sections[indexPath.section];

Person *person = peopleInSection[indexPath.row];

cell.textLabel.text = [NSString stringWithFormat:@“%@ %@“, person.firstName,

person.lastName];

cell.detailTextLabel.text = person.email;

return cell;

}

Page 34: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use Refactor Method judiciously

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *) indexPath {

UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@“cell”];

Person *person = [self personAtIndexPath:indexPath];

cell.textLabel.text = [NSString stringWithFormat:@“%@ %@“, person.firstName,

person.lastName];

cell.detailTextLabel.text = person.email;

return cell;

}

Page 35: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use Refactor Method judiciously

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *) indexPath {

UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@“cell”];

Person *person = [self personAtIndexPath:indexPath];

cell.textLabel.text = person.fullName;

cell.detailTextLabel.text = person.email;

return cell;

}

Page 36: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use Refactor Method judiciously

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *) indexPath {

UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@“cell”];

Person *person = [self personAtIndexPath:indexPath];

[self updateCell:cell forPerson:person];

return cell;

}

Page 37: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Understand Dependencies

method1 method2

Page 38: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Understand Dependencies

Page 39: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Understand Dependencies

Page 40: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Understand Dependencies

Page 41: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Keep your dependencies in check

OO is your friend

Page 42: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

objc-dependency-visualizer

http://paultaykalo.github.io/objc-dependency-visualizer

Page 43: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://jomnius.blogspot.com/2012/01/dependency-graph-tool-for-ios-projects.html

Page 44: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://jomnius.blogspot.com/2012/01/dependency-graph-tool-for-ios-projects.html

Page 45: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Reduce Dependencies by…

Loose Coupling Programming to interfaces

Dependency Inversion Reduce God Objects Reduce Singletons

Page 46: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

With Less Dependencies you can…

Refactor Change your mind

Change your implementation Add features

Page 47: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“Ruthlessly modularize functionality. Design, implement, and package everything as if it were to be distributed as 3rd-party

code”

Page 48: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“Ruthlessly modularize functionality. Design, implement, and package everything as if it were to be distributed as 3rd-party

code”

Page 49: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Mattt Thompson

Page 50: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Slim down your classes

Page 51: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Slim down your classes

Page 52: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Try to impose limits

Page 53: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Challenge Yourself

Photograph by Mikey Schaefer

Page 54: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Max LOC for .m: ~150

Max LOC for method: 4-5

Cesare Rocchi

Page 55: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Automate it

Page 56: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

awk

Page 57: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

find "${SRCROOT}" \(-name "*.h" -or -name "*.m"\) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 wc -l | awk '$1 > 400 && $2 != "total" { for(i=2;i<NF;i++) { printf "%s%s", $i, " “ } print $NF ":1: warning: File more than 400 lines (" $1 "), consider refactoring." }'

http://matthewmorey.com/improved-xcode-build-phases/

Page 58: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Xcode Tips

Page 59: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Completing Methods

Page 60: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“- ta”

Page 61: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Label your views in Interface Builder

Page 62: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Learn Keyboard Shortcuts

Photo credit: Wikipedia

Page 63: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘0

Page 64: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⌥0

Page 65: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⇧J

Page 66: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⇧Y

Page 67: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⇧C

Page 68: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⌃J ⌘⌃←

Page 69: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Jump in Assistant, back

Page 70: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌘⌃E (Edit all in Scope)

Page 71: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

⌃I (Re-indent selection)

Page 72: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

So many to learn

Page 73: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Pick 2 you don’t know

Page 74: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Deliberately Practice them

Page 75: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Repeat.

Page 76: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 77: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Snippets

Page 78: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Xcode / TextExpander

Page 79: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“pns” @property (nonatomic, strong)

Page 80: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“propint” @property (nonatomic, assign) NSInteger

Page 81: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“propstr” @property (nonatomic, copy) NSString *

Page 82: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“mark” #pragma mark -

Page 83: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

#pragma mark 🙈🙉🙊

Page 84: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

#pragma mark 💩

Page 85: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“tvds”

Page 86: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“swf”

Page 87: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“tvdel”

Page 88: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“networkact” [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

Page 89: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Repetitive code? Boilerplate code?

!

Make a snippet.

Page 90: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Source Control Tips

Page 91: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

(git)

Page 92: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Use the command

line

Page 93: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Leverage GUIs for specific tasks

Page 94: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://rowanj.github.io/gitx/GitX

Page 95: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Commits aren’t just ⌘S

Page 96: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Commit in logical chunks.

Page 97: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Write a good commit message

Page 98: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

Capitalized, short (50 chars or less) summary !More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. !Write your commit message in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug." This convention matches up with commit messages generated by commands like git merge and git revert. !Further paragraphs come after blank lines. !- Bullet points are okay, too !- Typically a hyphen or asterisk is used for the bullet, followed by a single space, with blank lines in between, but conventions vary here !- Use a hanging indent

Page 99: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

$ git log --oneline !9511f6c Add mixpanel gem 47a3e6d Add a sleep to not get throttled by facebook ce30dcb Kick Jenkins build 2e6802f Merge pull request #981 from DeliRadio/venue-favorites-rabls 99eb628 stub master account to avoid fail when run in test suite. b4e0435 before(:all) -> before(:each) to avoid certain test to fail when execute e4b10b6 Update schema 7b1e053 Fix banner check for venues in autocomplete 83ca7cb Update ci reporter 6eae32f Fix admin manages events spec. 7c8902b Add new line at the end of file so Github likes it. a153a48 Call Rails.application.eager_load! right before it is needed so that its 4a4d050 Refactoring test so it finishes faster. 4155ac6 fix crash when correcting country code from geolocated params 08c5bdb Proper auth token generation for facebook login: 4efaf1e Venue needs to have shareable_id and shareable_type implementation. Defa a9cdd7a Implemented a test to check shareable_id and shareable_type. Since Favor 9e1e6c2 fix after_party task syntax dde3ae9 add after_party task to fill in fb birthdays where we can 6e99a74 Implemented tests to check renderability of all ActiveRecord instance th b174af9 Added four templates that are required for favoritable items. 07218a0 year_of_birth, not birth_year be562bf update attribs from fb even for existing users 29041f0 Add logging to facebook oauth responses

Page 100: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 101: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Branches are basically free

Page 102: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 103: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

REBASELearn to

Page 104: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

master

origin/master

Page 105: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

master origin/master

Page 106: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

master

origin/master

MERGE METHOD “git pull” by default

Page 107: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

master origin/master

Page 108: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

master

origin/master

REBASE METHOD

Page 109: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

99% of the time you want !

git pull --rebase

Page 110: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Make this the default

git config branch.autosetuprebase always

Page 111: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Never rebase public branches

Page 112: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect

Page 113: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 114: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect start

Page 115: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect bad

Page 116: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git checkout HEAD~15

Page 117: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect good

Page 118: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

?

Page 119: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect bad

Page 120: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect bad

Page 121: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 122: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect good

Page 123: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 124: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect good

Page 125: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 126: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect good

Page 127: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 128: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git bisect run <script>

Page 129: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Oops, I made a git mistake!

Page 130: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

git reflog

Page 131: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 132: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Branch Per Feature

Page 133: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Keep Master Releasable

Page 134: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Don’t veer too far from working software

Page 135: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“I attempt to keep the app in a working state as much as possible. That means test driving small changes, committing often, and only

hooking things up to the UI when I think they're ready…”

Page 136: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“… If I'm not in a position to push my code at least every hour or so, I feel like I haven't broken my work down properly”

Page 137: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Stew Gleadow

Page 138: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://collectorcare.blogspot.com/

Page 139: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

http://cobcottagegifts.com/

Page 140: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Effective Habits

Page 141: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“I'm not a great programmer; I'm just a good programmer with great habits.” !

- Kent Beck

Page 142: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Keep an improvement list !

!

Page 143: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Have a side project !

!

Page 144: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Read Other People’s Code

Page 145: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“I form opinions about the code I study. Not all of it is good. I want to reflect on why I

feel that way.”

Page 146: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Jonathan Penn

Page 147: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Learn how to ask for help

Page 148: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 149: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 150: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Don’t ask !

Questions.5

Page 151: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Ask !

Question.1

Page 152: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Distill The

Problem

Page 153: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Reduce Variables

Page 154: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Also works for:

Page 155: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“Before asking for advice, take a careful look at what you know and what you are looking to have answered. Often that will put you in a spot where you answer your own question.” ! !

Page 156: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Daniel Steinberg

Page 157: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts
Page 158: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Program in other Languages

Page 159: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

“Don't just program in Objective C, make sure you regularly use another language. There is a lot we can learn from other technologies and communities” !

- Stew Gleadow ! !

Page 160: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Write Tests.

Page 161: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Go Forth, and be

Effective

Page 162: Tips & Tricks of Effective - Chariot Solutionschariotsolutions.com/wp-content/uploads/... · Tips & Tricks of Effective iOS Developers. BEN SCHEIRMAN @subdigital. Weekly Screencasts

Thank youBEN SCHEIRMAN

@subdigital chaione.com