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
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
9
4.2k
Hanami and htmx
bkuhlmann
0
220
ゆるい個人開発のススメ
kuroppe1819
10
1k
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
400
What We Can Learn From OSS
inouehi
0
430
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
300
AmperとFleetを使ったAndroidアプリ
yoppie
0
250
Ruby Function Composition
bkuhlmann
1
340
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
120
try! Swift Tokyo 初参加報告LT
hinakko2
0
230
Snowflakeで眠ったデータを起こそう!
estie
0
140
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
117
18k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
The Pragmatic Product Professional
lauravandoore
26
5.8k
We Have a Design System, Now What?
morganepeng
44
6.8k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
19
6.9k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
Scaling GitHub
holman
457
140k
BBQ
matthewcrist
80
8.8k
It's Worth the Effort
3n
180
27k
Being A Developer After 40
akosma
66
580k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
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!