Upgrade to Pro — share decks privately, control downloads, hide ads and more …

『タップル誕生』のコーディング規約 と 検討中のアーキテクチャ

tomohiro_sasaki
October 18, 2017
820

『タップル誕生』のコーディング規約 と 検討中のアーキテクチャ

tomohiro_sasaki

October 18, 2017
Tweet

Transcript

  1. Survey - Github https://github.com/github/swift-style-guide - eureka https://github.com/eure/swift-style-guide/blob/master/README_jp.md - ϦΫϧʔτϥΠϑελΠϧ https://github.com/recruit-lifestyle/swift-style-guide

    - εϚʔτςοΫɾϕϯνϟʔζ https://github.com/SmartTechVentures/swift-style-guide - Wantedly http://qiita.com/susieyy/items/f71435cc962e70d81b37
  2. How

  3. [weak self]ͷguard letͷself Ͳ͏͢Δʁ guard let `self` = self else

    { return } guard let wSelf = self else { return } guard let me = self else { return }
  4. [weak self]ͷguard letͷself Ͳ͏͢Δʁ guard let `self` = self else

    { return } guard let wSelf = self else { return } guard let me = self else { return }
  5. ܕਪ࿦Ͳ͏͢Δʁ // Good let title = “Tapple” // Bad let

    title: String = “Tapple” // Good let groups = [String]() // Bad let groups: [String] = [] let groups: [String] = [String]() // Good let score = CGFloat(0) // Bad let score: CGFloat = 0 ࢖͏ʂ
  6. array/dictionary͸ܕΛॻ͍ͨํ͕
 Ϗϧυ͕ૣ͍Β͍͔͠Β͠·ͤΜ͔ʁ ͦ͏͠Α͏ʂ // Good let title = “Tapple” //

    Bad let title: String = “Tapple” // Good let score = CGFloat(0) // Bad let score: CGFloat = 0 // Good let groups = [String]() // Bad let groups: [String] = [] let groups: [String] = [String]() array/dictionary͸ܕਪ࿦͠ͳ͍
  7. IBOutletͷม਺ʹ֎͔ΒΞΫηε͠ͳ͍ͱ͖ ͸fileprivate͚ͭͨํ͕ྑ͘ͳ͍ʁ @IBOutlet fileprivate weak var title: UILabel! @IBOutlet weak

    var title: UILabel? - ͚ͭΔ - ଞͷΫϥε͔Βࢀর͢Δͱ͖͸ʁʹ͢Δ swift4Ͱprivateͷڍಈ͕มΘͬͨͷͰ ͜͜͸privateʹͳΓ·ͨ͠
  8. UserRepositoryʹ͍ͭͯ final class UserRepository { static let shared = UserRepository()

    private let apiClient: ApiClientType private let bag = DisposeBag() let updatedUser: Observable<UserEntity> private let _updatedUser = PublishSubject<UserEntity>() init(apiClient: ApiClientType = UserApiClientMock()) { self.apiClient = apiClient self.updatedUser = _updatedUser } func updateUser(user: UserEntity) -> Observable<Error> { return apiClient.updateUser(user) .do(onNext: { [weak self] in self?._updatedUser.onNext($0) }) .flatMap { _ in Observable<Error>.empty() } .catchError { .just($0) } } } 7JFX.PEFM͸͜ΕΛ؂ࢹ
  9. End