@mmerterden/multi-agent-pipeline 20.7.0 → 20.8.0
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 +9 -0
- package/LICENSE +0 -10
- package/docs/facts.json +1 -1
- package/manifest.json +266 -267
- package/package.json +2 -2
- package/pipeline/scripts/_notices.mjs +1 -1
- package/pipeline/skills/.skill-manifest.json +68 -68
- 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 +339 -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 +105 -122
- package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +143 -166
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +307 -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 +333 -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 +265 -381
- package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
- package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +133 -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 +270 -382
- package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
- package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +169 -317
- 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 +226 -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 +292 -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 +230 -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/mapkit-location/SKILL.md +295 -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/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 +298 -242
- 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 +303 -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 +180 -161
- 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 +408 -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 +352 -472
- 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 +396 -457
- package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
- package/pipeline/skills/shared/external/swift-testing/SKILL.md +188 -175
- package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
- package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +80 -84
- package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
- package/pipeline/skills/shared/external/swiftdata/SKILL.md +392 -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 +193 -168
- package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
- package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +132 -133
- package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
- package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +106 -140
- 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 +152 -310
- package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
- package/pipeline/skills/shared/external/widgetkit/SKILL.md +216 -288
- package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +414 -719
- package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
|
@@ -1,451 +1,326 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: swift-api-design-guidelines
|
|
3
|
-
description: "Swift API Design Guidelines: clarity
|
|
3
|
+
description: "Swift API Design Guidelines: call-site clarity over brevity, argument labels and prepositions, method versus property, side-effect naming, mutating and nonmutating pairs, make factories, protocol and generic parameter names, casing, doc comments, complexity notes. Use when naming types, methods, properties or parameters, writing doc comments or reviewing an API for standard-library consistency. Not for language features, concurrency or lint config."
|
|
4
4
|
metadata:
|
|
5
|
-
source:
|
|
5
|
+
source: multi-agent-pipeline
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Swift API Design Guidelines
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let value = Int64(someUInt32)
|
|
46
|
-
let str = String(someCharacter)
|
|
47
|
-
|
|
48
|
-
// Narrowing or lossy conversions keep a label
|
|
49
|
-
let approx = Int64(truncating: someDecimal)
|
|
50
|
-
let str = String(describing: someObject)
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Indistinguishable arguments.** When all arguments cannot be usefully distinguished, omit all labels.
|
|
54
|
-
|
|
55
|
-
```swift
|
|
56
|
-
// GOOD - arguments are peers
|
|
57
|
-
let smaller = min(x, y)
|
|
58
|
-
zip(sequence1, sequence2)
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### When to use a prepositional label
|
|
62
|
-
|
|
63
|
-
**Prepositional phrase rule.** When the first argument completes a prepositional phrase with the base name, label it with the preposition.
|
|
64
|
-
|
|
65
|
-
```swift
|
|
66
|
-
// GOOD - "remove boxes having length 12"
|
|
67
|
-
x.removeBoxes(havingLength: 12)
|
|
68
|
-
|
|
69
|
-
// GOOD - "fade from red"
|
|
70
|
-
view.fade(from: red)
|
|
71
|
-
|
|
72
|
-
// GOOD - "relative path from root"
|
|
73
|
-
path.relativePath(from: root)
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Exception - abstraction boundary.** When the first two arguments represent parts of a single abstraction, fold the preposition into the base name so each component gets its own label.
|
|
77
|
-
|
|
78
|
-
```swift
|
|
79
|
-
// GOOD - x and y are parts of a single abstraction (a point)
|
|
80
|
-
a.moveTo(x: b, y: c)
|
|
81
|
-
|
|
82
|
-
// BAD - preposition attaches to first arg, leaving y unlabeled
|
|
83
|
-
a.move(toX: b, y: c)
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Default: label everything else
|
|
87
|
-
|
|
88
|
-
When no special rule above applies, label the argument.
|
|
89
|
-
|
|
90
|
-
```swift
|
|
91
|
-
// GOOD
|
|
92
|
-
array.split(maxSplits: 2)
|
|
93
|
-
button.setTitle("OK", for: .normal)
|
|
94
|
-
controller.dismiss(animated: true)
|
|
95
|
-
array.sorted(by: >)
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Argument label decision table
|
|
10
|
+
Use this when choosing names for types, methods, properties, parameters and
|
|
11
|
+
argument labels, and when writing the doc comments that go with them. Baseline:
|
|
12
|
+
Swift 6.3.
|
|
13
|
+
|
|
14
|
+
Out of scope, with where it goes instead:
|
|
15
|
+
|
|
16
|
+
- Language features and syntax, such as `some` versus `any`: `swift-language`.
|
|
17
|
+
- Concurrency: `swift-concurrency`.
|
|
18
|
+
- Lint rules and configuration: `swiftlint`.
|
|
19
|
+
|
|
20
|
+
When a request mixes these, answer the naming part briefly, then point to the
|
|
21
|
+
sibling skill for the rest. Do not start implementing the sibling's domain.
|
|
22
|
+
|
|
23
|
+
## Argument labels
|
|
24
|
+
|
|
25
|
+
Decide the first argument's label by testing these in order; the first rule
|
|
26
|
+
that applies wins.
|
|
27
|
+
|
|
28
|
+
1. **Grammatical phrase.** If the first argument reads as part of a phrase that
|
|
29
|
+
starts in the base name, drop its label and move any leading words into the
|
|
30
|
+
base name: `addSubview(y)`, not `add(subview: y)`.
|
|
31
|
+
2. **Conversion initializer.** A value-preserving (widening) conversion takes
|
|
32
|
+
no first label: `Int64(someUInt32)`, `String(someCharacter)`. A narrowing
|
|
33
|
+
or lossy one keeps a label that says so: `Int64(truncating:)`,
|
|
34
|
+
`String(describing:)`.
|
|
35
|
+
3. **Indistinguishable peers.** When the arguments cannot usefully be told
|
|
36
|
+
apart, label none of them: `min(x, y)`, `zip(names, scores)`.
|
|
37
|
+
4. **Prepositional phrase.** When the base name ends in a preposition that the
|
|
38
|
+
first argument finishes, the preposition becomes the label: `removeBoxes(havingLength: 12)`,
|
|
39
|
+
`fade(from: red)`, `relativePath(from: root)`.
|
|
40
|
+
5. **One abstraction, several arguments.** If the first two arguments are parts
|
|
41
|
+
of a single idea, keep the preposition in the base name so each part gets
|
|
42
|
+
its own label: `moveTo(x: b, y: c)`, not `move(toX: b, y: c)`.
|
|
43
|
+
6. **Otherwise, label it:** `split(maxSplits: 2)`, `setTitle("OK", for: .normal)`,
|
|
44
|
+
`dismiss(animated: true)`, `sorted(by: >)`.
|
|
99
45
|
|
|
100
46
|
| Situation | Rule | Example |
|
|
101
|
-
|
|
102
|
-
|
|
|
103
|
-
| Value-preserving init
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
109
|
-
For extended examples and edge cases, see [references/argument-labels-and-parameters.md](references/argument-labels-and-parameters.md).
|
|
110
|
-
|
|
111
|
-
## Side-Effect Naming
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| Reads as a grammatical phrase | no label; merge words into the base name | `addSubview(y)` |
|
|
49
|
+
| Value-preserving init | no first label | `Int64(someUInt32)` |
|
|
50
|
+
| Peers | no labels | `min(x, y)` |
|
|
51
|
+
| Prepositional phrase | preposition is the label | `fade(from: red)` |
|
|
52
|
+
| Two args, one abstraction | preposition in the base name | `cellAt(row:column:)` |
|
|
53
|
+
| Anything else | label | `split(maxSplits: 2)` |
|
|
112
54
|
|
|
113
|
-
|
|
55
|
+
Edge cases, conversion kinds, parameter names and default arguments:
|
|
56
|
+
[the argument labels reference](references/argument-labels-and-parameters.md).
|
|
114
57
|
|
|
115
|
-
|
|
58
|
+
## Method or property
|
|
116
59
|
|
|
117
|
-
|
|
60
|
+
A property answers a question about the receiver. Make it a property when it
|
|
61
|
+
takes no arguments, has no side effects and cannot fail; callers will assume
|
|
62
|
+
it is cheap, so if it is not O(1), document the cost. Make it a method when it
|
|
63
|
+
needs input, changes state, can throw or suspend, or does work heavy enough
|
|
64
|
+
that a property would mislead.
|
|
118
65
|
|
|
119
66
|
```swift
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### Functions without side effects - nouns or adjective phrases
|
|
128
|
-
|
|
129
|
-
When a function returns a result without mutating anything, name it as a noun phrase, adjective phrase, or read as a description of what it returns.
|
|
130
|
-
|
|
131
|
-
```swift
|
|
132
|
-
// Pure - noun/description
|
|
133
|
-
let d = point.distance(to: origin)
|
|
134
|
-
let area = rect.intersection(other)
|
|
135
|
-
let line = text.trimmingCharacters(in: .whitespaces)
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Boolean properties and methods
|
|
139
|
-
|
|
140
|
-
Boolean properties and methods read as assertions about the receiver.
|
|
141
|
-
|
|
142
|
-
```swift
|
|
143
|
-
// GOOD - reads as "line is empty"
|
|
144
|
-
line.isEmpty
|
|
145
|
-
set.contains(element)
|
|
146
|
-
url.isFileURL
|
|
147
|
-
|
|
148
|
-
// BAD - not an assertion
|
|
149
|
-
line.empty // verb? adjective?
|
|
150
|
-
set.includes // incomplete phrase
|
|
67
|
+
protocol TrackList {
|
|
68
|
+
var trackCount: Int { get } // a fact about the receiver
|
|
69
|
+
var isEmpty: Bool { get }
|
|
70
|
+
func tracks(by artist: Artist) -> [Track] // needs input
|
|
71
|
+
mutating func shuffle() // changes state
|
|
72
|
+
func loadArtwork() async throws -> Image // real work that can fail
|
|
73
|
+
}
|
|
151
74
|
```
|
|
152
75
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
## Mutating and Nonmutating Pairs
|
|
76
|
+
More in [the naming reference](references/naming-and-clarity.md).
|
|
156
77
|
|
|
157
|
-
|
|
78
|
+
## Naming by side effect
|
|
158
79
|
|
|
159
|
-
|
|
80
|
+
- **Mutating** operations are imperative verb phrases: `sort()`,
|
|
81
|
+
`append(newElement)`, `remove(at:)`, `invalidate()`.
|
|
82
|
+
- **Non-mutating** operations read as noun phrases, adjective phrases or a
|
|
83
|
+
description of what comes back: `distance(to:)`, `intersection(_:)`,
|
|
84
|
+
`trimmingCharacters(in:)`.
|
|
85
|
+
- **Booleans** should state something true or false about the receiver: `isEmpty`,
|
|
86
|
+
`contains(_:)`, `isFileURL`. Avoid `empty` (verb or adjective?) and
|
|
87
|
+
`includes` (an unfinished phrase).
|
|
160
88
|
|
|
161
|
-
|
|
162
|
-
- **Mutating:** imperative verb (`sort`, `append`, `reverse`)
|
|
163
|
-
- **Nonmutating:** past participle `-ed` or present participle `-ing`
|
|
89
|
+
### Mutating and non-mutating pairs
|
|
164
90
|
|
|
165
|
-
|
|
91
|
+
When both forms exist, name them as a pair.
|
|
166
92
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
| `append(y)` | `appending(y)` | `-ing` - `appended` does not describe the returned receiver clearly |
|
|
173
|
-
| `stripNewlines()` | `strippingNewlines()` | `-ing` - direct-object pattern from the guidelines |
|
|
93
|
+
**Verb operations.** The mutating form is the imperative verb. The
|
|
94
|
+
non-mutating form adds `-ed` by default, when "a [verb]-ed [noun]" describes
|
|
95
|
+
the result. Fall back to `-ing` only when `-ed` is ungrammatical or would
|
|
96
|
+
describe the direct object instead of the returned value. A direct object is a
|
|
97
|
+
hint to run that grammar check, not a rule by itself.
|
|
174
98
|
|
|
175
|
-
|
|
99
|
+
| Mutating | Non-mutating | Why |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `sort()` | `sorted()` | `-ed` default |
|
|
102
|
+
| `reverse()` | `reversed()` | `-ed` default |
|
|
103
|
+
| `sortLines()` | `sortedLines()` | `-ed` describes the result |
|
|
104
|
+
| `append(y)` | `appending(y)` | `appended` would not describe the returned receiver |
|
|
105
|
+
| `stripNewlines()` | `strippingNewlines()` | `-ed` would name the removed newlines |
|
|
176
106
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- **Mutating:** `form` prefix (`formUnion`, `formIntersection`)
|
|
107
|
+
**Noun operations.** The non-mutating form is the noun; the mutating form
|
|
108
|
+
takes a `form` prefix:
|
|
180
109
|
|
|
181
110
|
```swift
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Mutating - modifies in place
|
|
186
|
-
a.formUnion(b)
|
|
111
|
+
let both = weekdays.union(weekend) // new value
|
|
112
|
+
weekdays.formUnion(weekend) // in place
|
|
187
113
|
```
|
|
188
114
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
let iterator = collection.makeIterator()
|
|
195
|
-
let buffer = parser.makeBuffer()
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
In mixed routing answers, briefly validate existing `make...` factory names before handing off unrelated type-system or linting details to sibling skills.
|
|
199
|
-
|
|
200
|
-
### Pair decision table
|
|
201
|
-
|
|
202
|
-
| Operation described by | Mutating name | Nonmutating name | Example pair |
|
|
203
|
-
|------------------------|---------------|-------------------|-------------|
|
|
204
|
-
| Verb (default) | verb | verb + `-ed` | `sort()` / `sorted()` |
|
|
205
|
-
| Verb (`-ed` is ungrammatical) | verb | verb + `-ing` | `stripNewlines()` / `strippingNewlines()` |
|
|
206
|
-
| Noun | `form` + Noun | noun | `formUnion(b)` / `union(b)` |
|
|
207
|
-
|
|
208
|
-
For the full -ed/-ing decision tree and expanded naming patterns, see [references/side-effects-and-mutating-pairs.md](references/side-effects-and-mutating-pairs.md).
|
|
115
|
+
| Kind | Mutating | Non-mutating |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| Verb (default) | verb | verb + `-ed` |
|
|
118
|
+
| Verb where `-ed` fails | verb | verb + `-ing` |
|
|
119
|
+
| Noun | `form` + Noun | noun |
|
|
209
120
|
|
|
210
|
-
|
|
121
|
+
**Factories** get a `make` prefix whenever they produce a fresh value: `makeIterator()`,
|
|
122
|
+
`makeBuffer()`. If a mixed request already uses `make...` names, confirm them
|
|
123
|
+
in a line before routing the rest.
|
|
211
124
|
|
|
212
|
-
|
|
125
|
+
Decision tree, `form` rules, Boolean and factory patterns:
|
|
126
|
+
[the side-effects reference](references/side-effects-and-mutating-pairs.md).
|
|
213
127
|
|
|
214
|
-
|
|
128
|
+
## Documentation comments
|
|
215
129
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
| Subscript | What it accesses |
|
|
220
|
-
| Initializer | What it creates |
|
|
221
|
-
| Type / property / variable | What it **is** |
|
|
130
|
+
Every public declaration gets one. The summary is a single sentence fragment
|
|
131
|
+
ending in a period, starting with a verb for actions and a noun phrase for
|
|
132
|
+
entities. What it says depends on the declaration:
|
|
222
133
|
|
|
223
|
-
|
|
134
|
+
| Declaration | Summary says |
|
|
135
|
+
|---|---|
|
|
136
|
+
| function or method | the action and its result |
|
|
137
|
+
| subscript | what it accesses |
|
|
138
|
+
| initializer | what it creates |
|
|
139
|
+
| type, property, variable | the thing itself |
|
|
224
140
|
|
|
225
141
|
```swift
|
|
226
|
-
|
|
227
|
-
|
|
142
|
+
protocol ReadingLog {
|
|
143
|
+
/// Returns the reading closest to `time`, or `nil` if there are none.
|
|
144
|
+
func reading(nearest time: Date) -> Reading?
|
|
228
145
|
|
|
229
|
-
/// The number of
|
|
230
|
-
var
|
|
146
|
+
/// The number of readings recorded today.
|
|
147
|
+
var todayCount: Int { get }
|
|
231
148
|
|
|
232
|
-
/// Creates a
|
|
233
|
-
init(
|
|
149
|
+
/// Creates a log that keeps at most `limit` readings.
|
|
150
|
+
init(limit: Int)
|
|
234
151
|
|
|
235
|
-
/// Accesses the
|
|
236
|
-
subscript(
|
|
152
|
+
/// Accesses the reading at `position`.
|
|
153
|
+
subscript(position: Int) -> Reading { get }
|
|
154
|
+
}
|
|
237
155
|
```
|
|
238
156
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
Use standard symbol markup after the summary when relevant:
|
|
242
|
-
|
|
243
|
-
- `- Parameter name:` for individual parameters
|
|
244
|
-
- `- Parameters:` block for multiple parameters
|
|
245
|
-
- `- Returns:` for the return value
|
|
246
|
-
- `- Throws:` for errors thrown
|
|
247
|
-
- `- Complexity:` for algorithmic complexity
|
|
157
|
+
After the summary, use symbol markup: `- Parameter name:`, a `- Parameters:`
|
|
158
|
+
block, `- Returns:`, `- Throws:`, `- Complexity:`.
|
|
248
159
|
|
|
249
160
|
```swift
|
|
250
|
-
|
|
251
|
-
///
|
|
252
|
-
///
|
|
253
|
-
/// -
|
|
254
|
-
///
|
|
255
|
-
|
|
161
|
+
protocol EditableReadingLog: ReadingLog {
|
|
162
|
+
/// Removes the reading at `position` and hands it back.
|
|
163
|
+
///
|
|
164
|
+
/// - Parameter position: The index of the reading to remove. Must be a
|
|
165
|
+
/// valid index of the log.
|
|
166
|
+
/// - Returns: The reading that was removed.
|
|
167
|
+
/// - Complexity: O(*n*) in the log's length.
|
|
168
|
+
@discardableResult
|
|
169
|
+
mutating func remove(at position: Int) -> Reading
|
|
170
|
+
}
|
|
256
171
|
```
|
|
257
172
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
Document the complexity of any computed property that is not O(1). Callers assume properties are O(1) by default. If a property does more than constant-time work, state the complexity explicitly.
|
|
173
|
+
A property looks free to call, so readers expect constant time. When a computed
|
|
174
|
+
property costs more, the doc comment has to say so:
|
|
261
175
|
|
|
262
176
|
```swift
|
|
263
|
-
/// The
|
|
177
|
+
/// The combined mass of every item in the crate.
|
|
264
178
|
///
|
|
265
|
-
/// - Complexity: O(*n*)
|
|
266
|
-
var
|
|
267
|
-
items.reduce(
|
|
179
|
+
/// - Complexity: O(*n*) in the item count.
|
|
180
|
+
var totalMass: Measurement<UnitMass> {
|
|
181
|
+
items.map(\.mass).reduce(Measurement(value: 0, unit: .kilograms), +)
|
|
268
182
|
}
|
|
269
183
|
```
|
|
270
184
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
3. **Using verb names for side-effect-free operations.** Naming a nonmutating method `sort()` that returns a new collection - use `sorted()` to signal no mutation.
|
|
400
|
-
|
|
401
|
-
4. **Naming by type instead of role.** Using `string` instead of `greeting`, or `array` instead of `elements`, when the role would be more informative.
|
|
402
|
-
|
|
403
|
-
5. **Missing documentation comments.** Leaving public declarations undocumented, or writing summaries that describe the implementation rather than the purpose.
|
|
404
|
-
|
|
405
|
-
6. **Not documenting non-O(1) computed properties.** Exposing a linear-time computed property without a `Complexity:` note, causing callers to assume O(1) and use it in loops.
|
|
406
|
-
|
|
407
|
-
7. **Applying form- prefix to verb-based operations.** Writing `formSort()` instead of just `sort()` - the `form` prefix is only for noun-based operations (`formUnion`).
|
|
408
|
-
|
|
409
|
-
8. **Factory methods without make- prefix.** Naming factory methods as `createIterator()` or `buildBuffer()` instead of `makeIterator()` and `makeBuffer()`.
|
|
410
|
-
|
|
411
|
-
9. **Repeating type information in names.** Writing `removeElement(cancelButton)` or `stringValue: String` when the type is already evident from context.
|
|
412
|
-
|
|
413
|
-
10. **Return-type-only overloads.** Defining overloads that differ only in return type, creating ambiguity when the compiler cannot infer the expected type.
|
|
414
|
-
|
|
415
|
-
11. **Unlabeled tuple members and closure parameters.** Exposing tuples or closures in public API without naming their components, forcing callers to use positional access.
|
|
416
|
-
|
|
417
|
-
## Review Checklist
|
|
418
|
-
|
|
419
|
-
### Argument Labels
|
|
420
|
-
- [ ] First argument follows the correct label rule (grammatical phrase, prepositional, conversion, or labeled)
|
|
421
|
-
- [ ] Prepositional labels do not incorrectly group independent arguments
|
|
422
|
-
- [ ] Value-preserving conversion initializers omit the first label
|
|
423
|
-
- [ ] All non-special-case arguments have labels
|
|
424
|
-
|
|
425
|
-
### Naming Semantics
|
|
426
|
-
- [ ] Mutating methods use imperative verb form
|
|
427
|
-
- [ ] Nonmutating methods use -ed/-ing or noun form
|
|
428
|
-
- [ ] Mutating/nonmutating pairs follow the correct pattern (verb pair or noun/form-noun pair)
|
|
429
|
-
- [ ] Boolean properties read as assertions (`isEmpty`, `isValid`, `contains`)
|
|
430
|
-
- [ ] Variables and parameters are named by role, not type
|
|
431
|
-
|
|
432
|
-
### Documentation
|
|
433
|
-
- [ ] Every public declaration has a doc comment
|
|
434
|
-
- [ ] Summaries are single sentence fragments ending in a period
|
|
435
|
-
- [ ] Summaries describe the correct thing per declaration kind (action, access, creation, entity)
|
|
436
|
-
- [ ] Non-O(1) computed properties document their complexity
|
|
437
|
-
- [ ] Parameters, return values, and thrown errors are documented with symbol markup
|
|
438
|
-
|
|
439
|
-
### Conventions
|
|
440
|
-
- [ ] Types and protocols use UpperCamelCase; everything else uses lowerCamelCase
|
|
441
|
-
- [ ] Acronyms are uniformly cased based on position
|
|
442
|
-
- [ ] Default arguments are preferred over method families
|
|
443
|
-
- [ ] Overloads do not differ only in return type
|
|
444
|
-
- [ ] Protocol names follow the noun (is-a) or suffix (capability) convention
|
|
185
|
+
## Clarity
|
|
186
|
+
|
|
187
|
+
The top priority is how the call reads where it is used; every other choice
|
|
188
|
+
serves that reader.
|
|
189
|
+
|
|
190
|
+
- **Clarity beats brevity.** A longer name that removes doubt is better. Do not
|
|
191
|
+
abbreviate. `remove(at: position)` says what `remove(position)` leaves open.
|
|
192
|
+
- **Include the words needed to avoid ambiguity.**
|
|
193
|
+
`friends.remove(at: index)`, not `friends.remove(index)`.
|
|
194
|
+
- **Omit words that only repeat type information.**
|
|
195
|
+
`allViews.remove(cancelButton)`, not `allViews.removeElement(cancelButton)`.
|
|
196
|
+
- **Name by role, not type.** `var greeting: String`, not `var string: String`;
|
|
197
|
+
`track(_ subscriber: Subscriber, for topic: String)`, not
|
|
198
|
+
`track(_ object: Subscriber, for string: String)`.
|
|
199
|
+
- **Compensate for weak types.** When a parameter is `Any`, `AnyObject`, `Int`
|
|
200
|
+
or `String`, the type says little; add a role word, as in
|
|
201
|
+
`addObserver(_:forKeyPath:)`, where `forKeyPath` explains the `String`.
|
|
202
|
+
|
|
203
|
+
Examples and terminology: [the naming reference](references/naming-and-clarity.md).
|
|
204
|
+
|
|
205
|
+
## Fluent call sites and protocols
|
|
206
|
+
|
|
207
|
+
Call sites should read as grammatical English: `insert(y, at: z)`,
|
|
208
|
+
`subviews.remove(at: i)`, `makeIterator()`. Not `insert(y, position: z)` or
|
|
209
|
+
`subviews.remove(i)`.
|
|
210
|
+
|
|
211
|
+
An initializer's first argument should not continue the type name as a
|
|
212
|
+
phrase: `Color(red:green:blue:)`, not `Color(havingRGBValuesRed:green:blue:)`.
|
|
213
|
+
|
|
214
|
+
Protocols:
|
|
215
|
+
|
|
216
|
+
- that say what something **is** are nouns: `Collection`, `IteratorProtocol`;
|
|
217
|
+
- that describe a **capability** end in `-able`, `-ible` or `-ing`:
|
|
218
|
+
`Equatable`, `Hashable`, `Sendable`.
|
|
219
|
+
|
|
220
|
+
Generic parameters follow the role rule too: `Element`, `Key`, `Value`,
|
|
221
|
+
`Base` when the parameter has a meaning in the API; a single letter such as
|
|
222
|
+
`T` only when it has none. Details in
|
|
223
|
+
[the naming reference](references/naming-and-clarity.md).
|
|
224
|
+
|
|
225
|
+
## Conventions
|
|
226
|
+
|
|
227
|
+
- Types and protocols are `UpperCamelCase`; everything else is
|
|
228
|
+
`lowerCamelCase`.
|
|
229
|
+
- Acronyms that are usually all capitals in American English are all upper or
|
|
230
|
+
all lower case depending on position: `utf8Bytes`, `isRepresentableAsASCII`,
|
|
231
|
+
`userSMTPServer`.
|
|
232
|
+
- Reach for a method or property before a free function. A free function fits
|
|
233
|
+
in three cases only: nothing is naturally `self` (`max(a, b)`), the function is
|
|
234
|
+
an unconstrained generic (`print(value)`), or the notation is established
|
|
235
|
+
in the domain (`sin(x)`).
|
|
236
|
+
- Give one method defaulted parameters rather than writing several methods
|
|
237
|
+
that vary only in the parameter list. Put defaulted parameters at the
|
|
238
|
+
end, and give them labels: they are usually left out, so when present they
|
|
239
|
+
must explain themselves.
|
|
240
|
+
|
|
241
|
+
```swift
|
|
242
|
+
// One entry point
|
|
243
|
+
func render(_ page: Page, scale: Double = 1, includesMargins: Bool = true) -> Image {
|
|
244
|
+
PageRasterizer(scale: scale, margins: includesMargins).draw(page)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Not a family such as render(_:), render(_:scale:) and
|
|
248
|
+
// render(_:scale:includesMargins:)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
- Two overloads can use one base name if they act on different kinds of types
|
|
252
|
+
or the shared meaning is obvious. Never overload on return type alone.
|
|
253
|
+
|
|
254
|
+
Casing tables, complexity, free functions, overloads, tuples and closures:
|
|
255
|
+
[the conventions reference](references/conventions-and-special-rules.md).
|
|
256
|
+
|
|
257
|
+
## Common mistakes
|
|
258
|
+
|
|
259
|
+
1. Dropping a needed label: `friends.remove(i)` where `friends.remove(at: i)`
|
|
260
|
+
is meant.
|
|
261
|
+
2. `-ed` where `-ing` is right: `stripped()` rather than `stripping()`. Test
|
|
262
|
+
whether "a [verb]-ed [noun]" reads naturally.
|
|
263
|
+
3. A verb for a side-effect-free operation: a non-mutating `sort()` should be
|
|
264
|
+
`sorted()`.
|
|
265
|
+
4. Naming by type: `string` for `greeting`, `array` for `elements`.
|
|
266
|
+
5. No doc comment, or a summary that describes the implementation instead of
|
|
267
|
+
the purpose.
|
|
268
|
+
6. An expensive computed property with no complexity note, so callers use it in
|
|
269
|
+
a loop.
|
|
270
|
+
7. `form` on a verb operation (`formSort()`); `form` is for noun operations
|
|
271
|
+
only.
|
|
272
|
+
8. Factories without `make`: `createIterator()`, `buildBuffer()`.
|
|
273
|
+
9. Repeating type information: `removeElement(cancelButton)`,
|
|
274
|
+
`stringValue: String`.
|
|
275
|
+
10. Overloads that differ only by return type, which confuse inference.
|
|
276
|
+
11. Unlabelled tuple members or closure parameters in public API, forcing
|
|
277
|
+
`.0` and `.1`.
|
|
278
|
+
|
|
279
|
+
## Review checklist
|
|
280
|
+
|
|
281
|
+
Argument labels
|
|
282
|
+
|
|
283
|
+
- [ ] The first argument follows the right rule: grammatical phrase,
|
|
284
|
+
prepositional, conversion, or labelled
|
|
285
|
+
- [ ] Prepositional labels do not tie together arguments that are independent
|
|
286
|
+
- [ ] Lossless conversion initializers take an unlabelled first argument
|
|
287
|
+
- [ ] Every argument not covered by a special rule has a label
|
|
288
|
+
|
|
289
|
+
Naming
|
|
290
|
+
|
|
291
|
+
- [ ] Mutating operations are imperative verbs
|
|
292
|
+
- [ ] Non-mutating operations use `-ed`, `-ing` or a noun
|
|
293
|
+
- [ ] Pairs follow the verb pattern or the noun / `form`-noun pattern
|
|
294
|
+
- [ ] Boolean names state a fact: `isEmpty`, `isValid`, `contains`
|
|
295
|
+
- [ ] Names describe roles, not types
|
|
296
|
+
|
|
297
|
+
Documentation
|
|
298
|
+
|
|
299
|
+
- [ ] Every public declaration is documented
|
|
300
|
+
- [ ] Each summary is one sentence fragment with a closing period
|
|
301
|
+
- [ ] The summary fits the declaration: action, access, creation or entity
|
|
302
|
+
- [ ] Non-O(1) computed properties state their complexity
|
|
303
|
+
- [ ] Symbol markup covers parameters, the return value and thrown errors
|
|
304
|
+
|
|
305
|
+
Conventions
|
|
306
|
+
|
|
307
|
+
- [ ] `UpperCamelCase` for types and protocols, `lowerCamelCase` for the rest
|
|
308
|
+
- [ ] Acronyms are cased uniformly by position
|
|
309
|
+
- [ ] Defaulted parameters instead of method families
|
|
310
|
+
- [ ] No overloads that differ only by return type
|
|
311
|
+
- [ ] Protocol names are nouns (what it is) or carry a capability suffix
|
|
445
312
|
|
|
446
313
|
## References
|
|
447
314
|
|
|
448
|
-
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
-
|
|
315
|
+
- [Argument labels and parameters](references/argument-labels-and-parameters.md):
|
|
316
|
+
prepositional edge cases, grammatical-phrase examples, conversion kinds,
|
|
317
|
+
parameter names for documentation, default arguments and ordering.
|
|
318
|
+
- [Naming and clarity](references/naming-and-clarity.md): needed and needless
|
|
319
|
+
words, role naming, weak types, method versus property, generic parameter
|
|
320
|
+
names, terminology.
|
|
321
|
+
- [Side effects and mutating pairs](references/side-effects-and-mutating-pairs.md):
|
|
322
|
+
in-place and copying examples, how to pick `-ed` or `-ing`, the `form`
|
|
323
|
+
prefix, Booleans, `make` factories.
|
|
324
|
+
- [Conventions and special rules](references/conventions-and-special-rules.md):
|
|
325
|
+
casing and acronyms, complexity notes, free-function exceptions, overload
|
|
326
|
+
safety, tuple and closure naming, unconstrained polymorphism.
|