From b1b1981ae525ca54711dd49ff7833c1467b26afa Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Sat, 30 Mar 2019 08:45:05 +0100 Subject: [PATCH] Added "Avoid specifying access control modifiers on extension level" section --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index e08fde8..f9f496f 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,32 @@ Gather IBOutlets in one group above all the other properties and keep them priva > Outlets are implementation detail and should be kept private. Gathering them in one grup above all the other properties is old convention. +### Avoid specifying access control modifiers on extension level + +Access control modifiers should not be specified on extension level: + +```swift +private extension MyType { + func method() { + // code using helper() + } + func helper() { ... } +} +``` + +But on member level: + +```swift +extension MyType { + fileprivate func method() { + // code using helper() + } + private func helper() { ... } +} +``` + +> This is to introduce distinction between members that should be visible from different types in the same file and those which should not. (`private extension` has the same result as `fileprivate extension` where all members end up being `fileprivate`). + ### Avoid double negation Don't not avoid double negation.