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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Delisa Mason
May 28, 2014
Programming
12
17k
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
430
AppKit for iOS Developers
kattrali
5
870
Crafting iOS Dev Tools in Redcar, the Ruby Editor
kattrali
2
810
Other Decks in Programming
See All in Programming
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.4k
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
350
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
170
CSC307 Lecture 11
javiergs
PRO
0
590
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
120
NOT A HOTEL - 建築や人と融合し、自由を創り出すソフトウェア
not_a_hokuts
2
570
株式会社 Sun terras カンパニーデック
sunterras
0
2k
CSC307 Lecture 15
javiergs
PRO
0
220
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
330
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
470
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
210
atmaCup #23でAIコーディングを活用した話
ml_bear
4
740
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
99
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
210
Mind Mapping
helmedeiros
PRO
1
110
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
280
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4k
GraphQLの誤解/rethinking-graphql
sonatard
75
11k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
300
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.1k
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!