Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Bad Cocoa
Search
Delisa Mason
May 28, 2014
Programming
12
16k
Bad Cocoa
How-to guide for building the kind of code you will deeply regret later
Delisa Mason
May 28, 2014
Tweet
Share
More Decks by Delisa Mason
See All by Delisa Mason
Pod for Great Good
kattrali
2
390
AppKit for iOS Developers
kattrali
5
760
Crafting iOS Dev Tools in Redcar, the Ruby Editor
kattrali
2
660
Other Decks in Programming
See All in Programming
プールにゆこう
irof
2
120
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
250
Designing for tomorrow's programming workflows
honnibal
PRO
2
110
入門 AWS Amplify Gen2 / Introduction to AWS Amplify Gen2
genkiogasawara
1
310
エンターテイメント業界で利用されるAWS
demuyan
0
200
Front-end application development, Symfony-style(s)
dunglas
2
1.9k
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.2k
今の SmartHR にエンジニアで入社するとどうなるの?
daisukeshinoku
5
4.6k
オブジェクト指向のリ・オリエンテーション~歴史を振り返り、AI時代に向きなおる~
hanyudaeiiti
9
5.6k
SwiftUI Performance 不要なViewの再描画と更新を抑える
bigamitiongit
1
160
甘い香りに誘われてVanilla Extractを1年間運用してみた
miyahkun
1
110
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
25
7.8k
Featured
See All Featured
Done Done
chrislema
178
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
990
Gamification - CAS2011
davidbonilla
76
4.6k
Docker and Python
trallard
33
2.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
GraphQLとの向き合い方2022年版
quramy
31
12k
In The Pink: A Labor of Love
frogandcode
138
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
The Power of CSS Pseudo Elements
geoffreycrofte
59
5k
The Language of Interfaces
destraynor
151
23k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
Transcript
Bad Cocoa How to write the code of deep regret
quickly and easily - @kattrali
Think Monolithic ensure changing one part of an app requires
changing them all
Long Selector is Best Selector
Test Private Stuff ensure every test will break during refactors
maximize the number of mocks, stubs, and performSelector() calls
Do Not Write Tests no worries, the compiler will catch
your bugs
Use Delegates with Callbacks If you don't need asynchronous callbacks
for synchronous code, you aren't trying hard enough -initWithDelegate:callback:
Subclass Subclass Subclass things will be easy when you need
to swap out superclasses sometime!
Categoriception Extend your own classes with several categories instead of
containing each unit of related functionality in a single class
Maximize Responsibilities Per Class ensure the difficulty of changing individual
components later
Safely assign many responsibilities using protocols @class MyController : NSObject
<MyControllerDelegate, Why, God, Please, Stop, WithTheProtocols>
Safely assign many responsibilities using protocols BONUS: Make each component
of a protocol optional, for maximum flexibility and verbosity (and less warnings!!)
Procrastinate on Performance always wait until you have a problem
before opening Instruments.app
if (@"Avoid Static Analysis") goto fail; goto fail;
Always Swing the Heaviest Hammer NSOperation and Core Data all
day every day - maximize boilerplate code (GCD and NSCoding don't real)
Make Code Styles Inconsistent increase the difficulty of using or
extending your project avoid code style tools like clang- format and Uncrustify
Do not write documentation especially avoid easy-to-use tooling like appledoc
Optimize early Reduce duplication as soon as possible, making code
less flexible later
When in doubt, add to AppDelegate There is no better
place to dump bits of code which do not belong anywhere and need access to application state certainly not new classes
#define over static variables get the most of your available
memory for your numbers, strings, and colors
Thank you!