* Avoid large callback blocks - instead organize them into methods. This makes weak-self in blocks much simpler.

```swift

// WRONG

classMyClass {

funcdoRequest(completion: () ->Void) {

API.request() { response in

// lots of processing and whatever

completion()

}

}

}

// RIGHT

classMyClass {

funcdoRequest(completion: () ->Void) {

API.request() { response in

self.processResponse(response)

completion()

}

}

funcprocessResponse(response) {

// do actual processing here

}

}

```

* Guard

* Only add to top of functions. Goal of guard is to reduce branch complexity and in some ways adding guard statements in the middle of a chunk of code increases complexity

* How do we deal with multiple let clauses in an if clause?

```swift

// This feels weird, but is how autoindent works right now in XCode

if

let val1 = val1,

let val2 = val2

where!val2.isEmpty {

print(val2)

}

// Putting the first let on the same line as the if makes the body indent an extra level

// This also looks kind of gross

iflet val1 = val1,

let val2 = val2

where!val2.isEmpty {

print(val2)

}

```

* Don’t include return type Void in blocks even though that’s what autocomplete does

```swift

// WRONG

someAsyncThing() { argument ->Voidin... }

// RIGHT

someAsyncThing() { argument in... }

```

* prefer immutable values whenever possible. use map and flatmap instead of appending to a new array. mutable variables increase complexity, so try to keep them in as small a scope as possible if you have to use them.