@mmerterden/multi-agent-pipeline 20.7.0 → 20.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +0 -10
- package/docs/facts.json +1 -1
- package/manifest.json +285 -285
- package/package.json +3 -3
- package/pipeline/lib/redact.mjs +3 -2
- package/pipeline/scripts/_notices.mjs +1 -1
- package/pipeline/scripts/gen-skills-index.mjs +13 -1
- package/pipeline/scripts/pre-commit-check.sh +4 -0
- package/pipeline/skills/.skill-manifest.json +69 -69
- package/pipeline/skills/shared/README.md +70 -70
- package/pipeline/skills/shared/external/alarmkit/SKILL.md +373 -381
- package/pipeline/skills/shared/external/alarmkit/evals/evals.json +23 -18
- package/pipeline/skills/shared/external/alarmkit/references/alarmkit-patterns.md +328 -378
- package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
- package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
- package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
- package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
- package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
- package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
- package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
- package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +345 -277
- package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
- package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +107 -121
- package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +145 -165
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +306 -326
- package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
- package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
- package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
- package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +335 -360
- package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
- package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
- package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
- package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
- package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
- package/pipeline/skills/shared/external/authentication/SKILL.md +277 -381
- package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
- package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +135 -178
- package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
- package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
- package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
- package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
- package/pipeline/skills/shared/external/background-processing/SKILL.md +274 -384
- package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
- package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +173 -321
- package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
- package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
- package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
- package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
- package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
- package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
- package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
- package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
- package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
- package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +228 -376
- package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
- package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
- package/pipeline/skills/shared/external/core-data/SKILL.md +302 -368
- package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
- package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
- package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
- package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
- package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
- package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
- package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
- package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
- package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
- package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
- package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
- package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
- package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
- package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
- package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
- package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
- package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
- package/pipeline/skills/shared/external/device-integrity/SKILL.md +236 -353
- package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
- package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
- package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
- package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
- package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
- package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
- package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
- package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
- package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
- package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
- package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
- package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
- package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
- package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
- package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
- package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
- package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
- package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
- package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
- package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
- package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
- package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
- package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
- package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
- package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
- package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
- package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
- package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
- package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
- package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
- package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
- package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
- package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
- package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
- package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
- package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
- package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +3 -3
- package/pipeline/skills/shared/external/localization-reuse-map/example-mapping.json +1 -1
- package/pipeline/skills/shared/external/localization-reuse-map/reference/format-and-output.md +8 -7
- package/pipeline/skills/shared/external/localization-reuse-map/reference/publish-and-snapshot.md +2 -2
- package/pipeline/skills/shared/external/localization-reuse-map/reference/sources-and-recipes.md +5 -2
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/_shared.py +100 -0
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-artifact.py +45 -26
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-spreadsheet.py +14 -16
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-annotations.py +12 -5
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-legacy-labels.py +2 -1
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/publish-confluence.py +6 -5
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-overlay.py +44 -18
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-legacy-values.py +5 -2
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-new-values.py +10 -11
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/scan-screen-keys.py +4 -33
- package/pipeline/skills/shared/external/localization-reuse-map/scripts/verify-map.py +12 -59
- package/pipeline/skills/shared/external/mapkit-location/SKILL.md +297 -267
- package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
- package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
- package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
- package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
- package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
- package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
- package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
- package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
- package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
- package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
- package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
- package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
- package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
- package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
- package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
- package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
- package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
- package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
- package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
- package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
- package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
- package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
- package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
- package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
- package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
- package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
- package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
- package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
- package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
- package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
- package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
- package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
- package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
- package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
- package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
- package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
- package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
- package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
- package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
- package/pipeline/skills/shared/external/skill-creator/template.md +7 -1
- package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
- package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
- package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
- package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
- package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
- package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
- package/pipeline/skills/shared/external/storekit/references/core-patterns.md +302 -241
- package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
- package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
- package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
- package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
- package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
- package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
- package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
- package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
- package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
- package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
- package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
- package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
- package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
- package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
- package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +304 -351
- package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
- package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
- package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
- package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
- package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
- package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
- package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
- package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
- package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
- package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
- package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
- package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
- package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
- package/pipeline/skills/shared/external/swift-security/SKILL.md +183 -162
- package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
- package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
- package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +411 -476
- package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
- package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
- package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
- package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
- package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
- package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
- package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +375 -491
- package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
- package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
- package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
- package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +397 -457
- package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
- package/pipeline/skills/shared/external/swift-testing/SKILL.md +191 -175
- package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
- package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +81 -84
- package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
- package/pipeline/skills/shared/external/swiftdata/SKILL.md +394 -256
- package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
- package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
- package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
- package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
- package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
- package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
- package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
- package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
- package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
- package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
- package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
- package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
- package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
- package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
- package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
- package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
- package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
- package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
- package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
- package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
- package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
- package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
- package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
- package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
- package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +201 -168
- package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
- package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +134 -133
- package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
- package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +111 -138
- package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
- package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
- package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
- package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
- package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
- package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
- package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
- package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
- package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
- package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
- package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
- package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
- package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
- package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
- package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
- package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
- package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
- package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
- package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
- package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
- package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
- package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
- package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
- package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
- package/pipeline/skills/shared/external/weatherkit/SKILL.md +160 -315
- package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
- package/pipeline/skills/shared/external/widgetkit/SKILL.md +224 -288
- package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +416 -719
- package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
|
@@ -1,219 +1,147 @@
|
|
|
1
1
|
# Conventions and Special Rules
|
|
2
2
|
|
|
3
|
-
Casing
|
|
3
|
+
Casing, complexity notes, when a free function is right, safe overloading,
|
|
4
|
+
labelled tuples and closures, and the traps of unconstrained polymorphism.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Casing
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [Free Function Exceptions](#free-function-exceptions)
|
|
10
|
-
- [Overload Safety](#overload-safety)
|
|
11
|
-
- [Tuple Member and Closure Parameter Naming](#tuple-member-and-closure-parameter-naming)
|
|
12
|
-
- [Unconstrained Polymorphism](#unconstrained-polymorphism)
|
|
8
|
+
`lowerCamelCase` covers functions, methods, properties, variables, constants,
|
|
9
|
+
enum cases and argument labels. Types and protocols use `UpperCamelCase`.
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
Acronyms and initialisms:
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
- At the start of a `lowerCamelCase` name, all lower case: `utf8Bytes`,
|
|
14
|
+
`htmlParser`, `urlSession`.
|
|
15
|
+
- In the middle or at the end, cased to match the position, which in practice
|
|
16
|
+
means all upper case: `isRepresentableAsASCII`, `userSMTPServer`.
|
|
17
|
+
- In type names, all upper case: `HTTPRequest`, `URLSessionTask`, `UTF8`.
|
|
18
|
+
- Words that began as acronyms but are now ordinary words take normal casing:
|
|
19
|
+
`radarDetector` / `RadarDetector`, `laserPrinter`, `scubaGear`, never
|
|
20
|
+
`RADARDetector`.
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
## Complexity notes
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
Document the complexity of any computed property or subscript that does more
|
|
25
|
+
than constant work.
|
|
21
26
|
|
|
22
27
|
```swift
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var userSMTPServer: SMTPServer
|
|
31
|
-
|
|
32
|
-
// Type names - acronym stays uppercase
|
|
33
|
-
struct HTTPRequest { ... }
|
|
34
|
-
class URLSessionTask { ... }
|
|
35
|
-
enum UTF8 { ... }
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Words that started as acronyms but are now common words follow standard casing:
|
|
39
|
-
|
|
40
|
-
```swift
|
|
41
|
-
// These are words, not acronyms
|
|
42
|
-
var radarDetector: RadarDetector // not "RADARDetector"
|
|
43
|
-
var laserPrinter: LaserPrinter // not "LASERPrinter"
|
|
44
|
-
var scubaGear: ScubaGear // not "SCUBAGear"
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Complexity Documentation
|
|
48
|
-
|
|
49
|
-
Callers assume computed properties are O(1). Document the complexity of any computed property or subscript that does more work.
|
|
50
|
-
|
|
51
|
-
```swift
|
|
52
|
-
/// The total number of nodes in the tree.
|
|
53
|
-
///
|
|
54
|
-
/// - Complexity: O(*n*), where *n* is the number of nodes.
|
|
55
|
-
var nodeCount: Int {
|
|
56
|
-
root.descendants.count
|
|
28
|
+
extension Outline {
|
|
29
|
+
/// The number of headings at every depth.
|
|
30
|
+
///
|
|
31
|
+
/// - Complexity: O(*n*), where *n* is the number of headings in the outline.
|
|
32
|
+
var headingCount: Int {
|
|
33
|
+
children.reduce(1) { $0 + $1.headingCount }
|
|
34
|
+
}
|
|
57
35
|
}
|
|
58
|
-
```
|
|
59
36
|
|
|
60
|
-
|
|
61
|
-
///
|
|
62
|
-
///
|
|
63
|
-
/// - Complexity: O(*k*), where *k* is
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
extension Playlist {
|
|
38
|
+
/// Accesses the track `offset` positions after the start.
|
|
39
|
+
///
|
|
40
|
+
/// - Complexity: O(*k*), where *k* is `offset`; tracks are walked with
|
|
41
|
+
/// `index(after:)`.
|
|
42
|
+
subscript(offset offset: Int) -> Track {
|
|
43
|
+
var position = tracks.startIndex
|
|
44
|
+
for _ in 0..<offset { position = tracks.index(after: position) }
|
|
45
|
+
return tracks[position]
|
|
46
|
+
}
|
|
68
47
|
}
|
|
69
48
|
```
|
|
70
49
|
|
|
71
|
-
|
|
50
|
+
Members that really are O(1), such as a stored `count`, `isEmpty` or `first`,
|
|
51
|
+
need no note.
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
// O(1) - no note needed
|
|
75
|
-
var count: Int { storage.count }
|
|
76
|
-
var isEmpty: Bool { count == 0 }
|
|
77
|
-
var first: Element? { storage.first }
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Free Function Exceptions
|
|
81
|
-
|
|
82
|
-
Prefer methods and properties to free functions. Use a free function only when one of these three conditions holds:
|
|
83
|
-
|
|
84
|
-
**1. No obvious `self`**
|
|
53
|
+
## Free functions
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
// GOOD - neither argument is more "self" than the other
|
|
88
|
-
min(x, y)
|
|
89
|
-
max(a, b)
|
|
90
|
-
zip(sequence1, sequence2)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**2. Unconstrained generic**
|
|
94
|
-
|
|
95
|
-
```swift
|
|
96
|
-
// GOOD - works on anything
|
|
97
|
-
print(value)
|
|
98
|
-
debugPrint(value)
|
|
99
|
-
```
|
|
55
|
+
Make it a method unless one of three exceptions applies:
|
|
100
56
|
|
|
101
|
-
|
|
57
|
+
| Exception | Examples |
|
|
58
|
+
|---|---|
|
|
59
|
+
| No obvious `self` | `min`, `max`, `zip` |
|
|
60
|
+
| Unconstrained generic | `print`, `debugPrint` |
|
|
61
|
+
| Established domain notation | `sin`, `cos`, `abs` |
|
|
102
62
|
|
|
103
63
|
```swift
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
cos(x)
|
|
107
|
-
abs(value)
|
|
64
|
+
let d = origin.distance(to: target) // method
|
|
65
|
+
// not: calculateDistance(from: origin, to: target)
|
|
108
66
|
```
|
|
109
67
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```swift
|
|
113
|
-
// BAD - has an obvious self
|
|
114
|
-
calculateDistance(from: pointA, to: pointB)
|
|
115
|
-
|
|
116
|
-
// GOOD
|
|
117
|
-
pointA.distance(to: pointB)
|
|
118
|
-
```
|
|
68
|
+
## Overloads
|
|
119
69
|
|
|
120
|
-
|
|
70
|
+
Sharing a base name is fine when the operations are the same idea with
|
|
71
|
+
different inputs, as with `contains(_:)` and `contains(where:)` on
|
|
72
|
+
`Collection`.
|
|
121
73
|
|
|
122
|
-
|
|
74
|
+
Overloading on the return type alone is not:
|
|
123
75
|
|
|
124
76
|
```swift
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
func
|
|
128
|
-
func contains(where predicate: (Element) -> Bool) -> Bool
|
|
77
|
+
protocol ConfigReader {
|
|
78
|
+
func parse() -> Int
|
|
79
|
+
func parse() -> String
|
|
129
80
|
}
|
|
130
|
-
```
|
|
131
81
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Overloads that differ only in return type create ambiguity when the compiler cannot infer the expected type.
|
|
135
|
-
|
|
136
|
-
```swift
|
|
137
|
-
// BAD - ambiguous at call site
|
|
138
|
-
func transform() -> Int { ... }
|
|
139
|
-
func transform() -> String { ... }
|
|
140
|
-
|
|
141
|
-
let result = transform() // error: ambiguous
|
|
82
|
+
let result = reader.parse() // ambiguous: which one?
|
|
142
83
|
```
|
|
143
84
|
|
|
144
|
-
|
|
85
|
+
Overloads that stay unambiguous differ in their first label or in their
|
|
86
|
+
argument types:
|
|
145
87
|
|
|
146
88
|
```swift
|
|
147
|
-
|
|
148
|
-
func
|
|
149
|
-
func
|
|
89
|
+
protocol AlbumStore {
|
|
90
|
+
func load(id: Album.ID) async throws -> Album
|
|
91
|
+
func load(title: String) async throws -> Album
|
|
92
|
+
}
|
|
150
93
|
|
|
151
|
-
|
|
152
|
-
func
|
|
153
|
-
func
|
|
94
|
+
protocol Canvas {
|
|
95
|
+
func stroke(_ rect: CGRect)
|
|
96
|
+
func stroke(_ path: CGPath)
|
|
97
|
+
}
|
|
154
98
|
```
|
|
155
99
|
|
|
156
|
-
##
|
|
157
|
-
|
|
158
|
-
Label tuple members and closure parameters in public API signatures. Positional access (`.0`, `.1`) is fragile and unreadable.
|
|
100
|
+
## Tuples and closures
|
|
159
101
|
|
|
160
|
-
|
|
102
|
+
Label tuple members and closure parameters in public signatures. `.0` and `.1`
|
|
103
|
+
are fragile and say nothing.
|
|
161
104
|
|
|
162
105
|
```swift
|
|
163
|
-
|
|
164
|
-
func
|
|
165
|
-
func
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
pos.x // clear
|
|
169
|
-
pos.y // clear
|
|
170
|
-
|
|
171
|
-
// BAD - unlabeled
|
|
172
|
-
func position() -> (Double, Double)
|
|
173
|
-
|
|
174
|
-
let pos = item.position()
|
|
175
|
-
pos.0 // what is this?
|
|
176
|
-
pos.1 // what is this?
|
|
106
|
+
protocol Chart {
|
|
107
|
+
func bounds() -> (min: Double, max: Double) // good
|
|
108
|
+
func span() -> (start: Date, end: Date) // good
|
|
109
|
+
func extent() -> (Double, Double) // avoid: which is which?
|
|
110
|
+
}
|
|
177
111
|
```
|
|
178
112
|
|
|
179
|
-
|
|
113
|
+
Closure parameters in higher-order APIs deserve descriptive names too; they
|
|
114
|
+
show up in documentation and completion:
|
|
180
115
|
|
|
181
|
-
|
|
116
|
+
- `filter(_ isIncluded: (Element) throws -> Bool)`
|
|
117
|
+
- `map<T>(_ transform: (Element) throws -> T)`
|
|
118
|
+
- `sort(by areInIncreasingOrder: (Element, Element) throws -> Bool)`
|
|
182
119
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
func filter(_ isIncluded: (Element) -> Bool) -> [Element]
|
|
186
|
-
func map<T>(_ transform: (Element) -> T) -> [T]
|
|
187
|
-
func sort(by areInIncreasingOrder: (Element, Element) -> Bool)
|
|
188
|
-
|
|
189
|
-
// BAD
|
|
190
|
-
func filter(_ predicate: (Element) -> Bool) -> [Element] // acceptable but less descriptive
|
|
191
|
-
func sort(by compare: (Element, Element) -> Bool) // "compare" is vague
|
|
192
|
-
```
|
|
120
|
+
`predicate` is acceptable but says less than `isIncluded`; `compare` is vague
|
|
121
|
+
about which order counts as true.
|
|
193
122
|
|
|
194
|
-
## Unconstrained
|
|
123
|
+
## Unconstrained polymorphism
|
|
195
124
|
|
|
196
|
-
|
|
125
|
+
Overloads that take `Any`, `AnyObject` or an unconstrained generic can match
|
|
126
|
+
calls meant for a more specific overload, silently.
|
|
197
127
|
|
|
198
128
|
```swift
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
func append(_
|
|
129
|
+
struct Batch<Element> {
|
|
130
|
+
private(set) var items: [Element] = []
|
|
131
|
+
|
|
132
|
+
mutating func append(_ element: Element) { items.append(element) }
|
|
133
|
+
mutating func append(_ elements: some Sequence<Element>) { items.append(contentsOf: elements) }
|
|
203
134
|
}
|
|
204
135
|
|
|
205
|
-
|
|
136
|
+
var mixed = Batch<Any>()
|
|
137
|
+
mixed.append([1, 2, 3]) // compiles, but is that one new element or three?
|
|
138
|
+
// Both overloads accept it; nothing at the call site says which ran.
|
|
206
139
|
```
|
|
207
140
|
|
|
208
|
-
|
|
141
|
+
Give the collection form its own label:
|
|
209
142
|
|
|
210
143
|
```swift
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
func append(_ element: Element)
|
|
214
|
-
func append(contentsOf sequence: some Sequence<Element>)
|
|
144
|
+
mutating func append(contentsOf elements: some Sequence<Element>) {
|
|
145
|
+
items.append(contentsOf: elements)
|
|
215
146
|
}
|
|
216
|
-
|
|
217
|
-
values.append(singleValue)
|
|
218
|
-
values.append(contentsOf: [2, 3, 4]) // always clear
|
|
219
147
|
```
|
package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md
CHANGED
|
@@ -1,184 +1,146 @@
|
|
|
1
1
|
# Naming and Clarity
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
How to decide which words a name needs, which it can lose, and how to choose
|
|
4
|
+
between a method and a property.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Words that must stay
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [Name by Role Not Type](#name-by-role-not-type)
|
|
10
|
-
- [Compensate for Weak Type Information](#compensate-for-weak-type-information)
|
|
11
|
-
- [Terminology Selection](#terminology-selection)
|
|
8
|
+
Test every call site: would a reader who has never seen the declaration know
|
|
9
|
+
what it does?
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
| Clear | Ambiguous | What the extra word resolves |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `cache.removeValue(forKey: k)` | `cache.remove(k)` | is `k` a key or a value? |
|
|
14
|
+
| `team.member(for: badgeID)` | `team.member(badgeID)` | what the argument identifies |
|
|
15
|
+
| `label.fade(from: previousColor)` | `label.fade(previousColor)` | is it the start or the end colour? |
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## Words that can go
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
dictionary.removeValue(forKey: key)
|
|
20
|
-
|
|
21
|
-
// BAD - is key the value or the lookup key?
|
|
22
|
-
dictionary.remove(key)
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
```swift
|
|
26
|
-
// GOOD - "for" clarifies the relationship
|
|
27
|
-
extension List {
|
|
28
|
-
func member(for key: Key) -> Value?
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// BAD - what is "key" relative to the list?
|
|
32
|
-
extension List {
|
|
33
|
-
func member(_ key: Key) -> Value?
|
|
34
|
-
}
|
|
35
|
-
```
|
|
19
|
+
A word earns its place only if it adds something the types and context do not
|
|
20
|
+
already say.
|
|
36
21
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
| Lean | Redundant |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `toolbar.remove(cancelButton)` | `toolbar.removeElement(cancelButton)` |
|
|
25
|
+
| `parser.parse(data)` | `parser.parseData(data)` |
|
|
26
|
+
| `sprite.move(to point: CGPoint)` | `sprite.moveToPoint(_ point: CGPoint)` |
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
view.fade(previousColor)
|
|
43
|
-
```
|
|
28
|
+
## Roles, not types
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
Variables, parameters and associated types should say what part they play,
|
|
31
|
+
not what type they happen to be.
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
| Role name | Type name |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `var greeting: String` | `var string: String` |
|
|
36
|
+
| `var bodyText: String` | `var text: String` |
|
|
37
|
+
| `var widthConstraint: NSLayoutConstraint` | `var constraint: NSLayoutConstraint` |
|
|
38
|
+
| `func restock(from supplier: Warehouse)` | `func restock(from warehouse: Warehouse)` |
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
allViews.remove(cancelButton)
|
|
52
|
-
|
|
53
|
-
// BAD - "Element" repeats the type constraint
|
|
54
|
-
allViews.removeElement(cancelButton)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```swift
|
|
58
|
-
// GOOD
|
|
59
|
-
let result = parser.parse(data)
|
|
60
|
-
|
|
61
|
-
// BAD - "Data" is already the parameter type
|
|
62
|
-
let result = parser.parseData(data)
|
|
63
|
-
```
|
|
40
|
+
Associated types follow the same rule; name them for their meaning in the
|
|
41
|
+
protocol:
|
|
64
42
|
|
|
65
43
|
```swift
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
protocol Ledger {
|
|
45
|
+
associatedtype Entry // good: the role in a ledger
|
|
46
|
+
associatedtype Index // good
|
|
47
|
+
}
|
|
48
|
+
// Avoid associatedtype names such as EntryType or IntegerIndex.
|
|
71
49
|
```
|
|
72
50
|
|
|
73
|
-
##
|
|
51
|
+
## Generic parameters
|
|
74
52
|
|
|
75
|
-
|
|
53
|
+
Generic parameters are named by role as well. When the parameter means
|
|
54
|
+
something in the API, say it: `Element`, `Key`, `Value`, `Base`, `Destination`.
|
|
76
55
|
|
|
77
56
|
```swift
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
let widthConstraint: NSLayoutConstraint
|
|
82
|
-
func restock(from supplier: Warehouse)
|
|
83
|
-
|
|
84
|
-
// BAD - describes the type
|
|
85
|
-
var string: String
|
|
86
|
-
var text: String
|
|
87
|
-
let constraint: NSLayoutConstraint
|
|
88
|
-
func restock(from warehouse: Warehouse)
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
For associated types in protocols, name by the role in the protocol's semantics:
|
|
92
|
-
|
|
93
|
-
```swift
|
|
94
|
-
// GOOD
|
|
95
|
-
protocol Container {
|
|
96
|
-
associatedtype Element
|
|
97
|
-
associatedtype Index
|
|
57
|
+
struct Pair<First, Second> {
|
|
58
|
+
var first: First
|
|
59
|
+
var second: Second
|
|
98
60
|
}
|
|
99
61
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
associatedtype IntegerIndex
|
|
62
|
+
protocol Journal {
|
|
63
|
+
associatedtype Entry
|
|
64
|
+
mutating func merge<Source: Sequence>(_ source: Source) where Source.Element == Entry
|
|
104
65
|
}
|
|
105
66
|
```
|
|
106
67
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
When a parameter type is `Any`, `AnyObject`, `NSObject`, or a fundamental type (`Int`, `String`, `Double`), the call site may lack enough context to convey meaning. Add clarifying words to the name.
|
|
68
|
+
Reach for a single letter (`T`, `U`) only when the parameter has no role worth
|
|
69
|
+
naming, as in a fully generic utility:
|
|
110
70
|
|
|
111
71
|
```swift
|
|
112
|
-
|
|
113
|
-
func addObserver(_ observer: NSObject, forKeyPath path: String)
|
|
114
|
-
func fill(with color: UIColor, alpha: Double)
|
|
115
|
-
func setTag(_ tag: Int, for view: UIView)
|
|
116
|
-
|
|
117
|
-
// BAD - weak types make the call site opaque
|
|
118
|
-
func add(_ object: NSObject, for string: String)
|
|
119
|
-
func fill(with any: UIColor, _ value: Double)
|
|
120
|
-
func set(_ value: Int, for object: UIView)
|
|
72
|
+
func swapValues<T>(_ a: inout T, _ b: inout T) { (a, b) = (b, a) }
|
|
121
73
|
```
|
|
122
74
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```swift
|
|
126
|
-
// GOOD - return context clarifies weak type
|
|
127
|
-
func maximumScore() -> Int
|
|
128
|
-
func playerName() -> String
|
|
75
|
+
Generic parameter names are `UpperCamelCase`, like other types.
|
|
129
76
|
|
|
130
|
-
|
|
131
|
-
func value() -> Int
|
|
132
|
-
func name() -> String
|
|
133
|
-
```
|
|
77
|
+
## Weak types need help
|
|
134
78
|
|
|
135
|
-
|
|
79
|
+
Some types carry almost no meaning on their own: `Any`, `AnyObject`,
|
|
80
|
+
`NSObject`, and fundamentals such as `Int`, `String` and `Double`. When a
|
|
81
|
+
parameter has one of these types, add a word that states its role.
|
|
136
82
|
|
|
137
|
-
|
|
83
|
+
| Clear | Unclear |
|
|
84
|
+
|---|---|
|
|
85
|
+
| `addObserver(_ observer: NSObject, forKeyPath path: String)` | `add(_ object: NSObject, for string: String)` |
|
|
86
|
+
| `fill(with color: Color, alpha: Double)` | `fill(with any: Any, _ value: Double)` |
|
|
87
|
+
| `setTag(_ tag: Int, for view: UIView)` | `set(_ value: Int, for object: UIView)` |
|
|
138
88
|
|
|
139
|
-
|
|
89
|
+
The same goes for return values:
|
|
140
90
|
|
|
141
91
|
```swift
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
beginners // not "neophytes"
|
|
145
|
-
|
|
146
|
-
// GOOD - term of art is precise and necessary
|
|
147
|
-
func sin(_ angle: Double) -> Double // "sine" is the term of art
|
|
92
|
+
func highestScore() -> Int // not value() -> Int
|
|
93
|
+
func captainName() -> String // not name() -> String
|
|
148
94
|
```
|
|
149
95
|
|
|
150
|
-
|
|
96
|
+
## Method or property
|
|
151
97
|
|
|
152
|
-
|
|
98
|
+
Properties read as facts about the receiver, and callers treat them as free.
|
|
99
|
+
Choose a property when all of these hold:
|
|
153
100
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// BAD - "List" means something different in CS (linked list)
|
|
159
|
-
struct List<Element> { ... } // if it's really an array
|
|
160
|
-
```
|
|
101
|
+
- no arguments;
|
|
102
|
+
- no observable side effects;
|
|
103
|
+
- cannot throw or suspend;
|
|
104
|
+
- O(1), or its complexity is documented.
|
|
161
105
|
|
|
162
|
-
|
|
106
|
+
Choose a method when any of these hold:
|
|
163
107
|
|
|
164
|
-
|
|
108
|
+
- it needs input;
|
|
109
|
+
- it changes state (then it is also a mutating verb);
|
|
110
|
+
- it can fail or must `await`;
|
|
111
|
+
- the cost is large enough that a property would invite misuse, for example
|
|
112
|
+
a network fetch or a full scan of a large store.
|
|
165
113
|
|
|
166
114
|
```swift
|
|
167
|
-
|
|
168
|
-
var
|
|
169
|
-
var characterIndex: Int
|
|
115
|
+
struct Inventory {
|
|
116
|
+
private(set) var items: [Item]
|
|
170
117
|
|
|
171
|
-
//
|
|
172
|
-
var
|
|
173
|
-
var charIdx: Int
|
|
174
|
-
```
|
|
118
|
+
var isEmpty: Bool { items.isEmpty } // O(1) fact
|
|
119
|
+
var itemCount: Int { items.count } // O(1) fact
|
|
175
120
|
|
|
176
|
-
|
|
121
|
+
/// The total stock value.
|
|
122
|
+
///
|
|
123
|
+
/// - Complexity: O(*n*), where *n* is the number of items.
|
|
124
|
+
var totalValue: Decimal { items.reduce(0) { $0 + $1.price } } // O(n), documented
|
|
177
125
|
|
|
178
|
-
|
|
126
|
+
func items(in category: Category) -> [Item] { // takes input
|
|
127
|
+
items.filter { $0.category == category }
|
|
128
|
+
}
|
|
179
129
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Array, Dictionary, Set // not Vector, Map, HashSet
|
|
183
|
-
sin(x), cos(x) // not sine(x), cosine(x)
|
|
130
|
+
mutating func restock(_ item: Item) { items.append(item) } // changes state
|
|
131
|
+
}
|
|
184
132
|
```
|
|
133
|
+
|
|
134
|
+
## Choosing terms
|
|
135
|
+
|
|
136
|
+
- **Common words first.** Say "skin", not "epidermis"; "beginners", not
|
|
137
|
+
"neophytes". Keep terms of art for places where their precision matters,
|
|
138
|
+
such as `sin(_:)`.
|
|
139
|
+
- **Never bend a term of art.** If you use one, use its accepted meaning. An
|
|
140
|
+
array-backed type should not be called `List`, because readers will expect
|
|
141
|
+
a linked list.
|
|
142
|
+
- **Avoid abbreviations** unless everyone in the domain uses them:
|
|
143
|
+
`backgroundColor` and `characterIndex`, not `bgColor` and `charIdx`.
|
|
144
|
+
- **Follow precedent**, even over a design that seems purer. Swift says
|
|
145
|
+
`Array`, `Dictionary` and `Set`, not `Vector`, `Map` and `HashSet`; `sin` and
|
|
146
|
+
`cos`, not `sine` and `cosine`.
|