Skip to content

Conversation

@ivan-magda
Copy link
Member

Задача: #APPS-1940

Коротко для Release Notes, в формате «Сделали/Добавили/Исправили N»:

  • Создан новый модуль ExamEGERussian для приложения экзаменов по русскому языку.
  • Добавлены необходимые файлы в Compile Sources для работы API.
  • При старте происходит регистрация пользователя с фейковым email и отписка от рассылок. (Используется реализация из адаптивного модуля)

Описание:
Анонимная авторизация пользователя в модули для экзаменов по русскому языку.

Сорян, неудобно будет проверять, нужно было разбить на несколько PR :)

Add compile sources files to the ExamEGERussian target to be able to use Stepic API's.
Create:
- Auth.plist - holds own the keys for performing API requests
- Config.plist - contains API's endpoints URL's
Create:
- UserRegistrationService - for anonymous user registration and login
- UserSubscriptionsService - for managing user subscriptions preferences
Create RootNavigationManager and assembly for services.
@ivan-magda ivan-magda requested review from Ostrenkiy and kvld July 4, 2018 18:30
@ivan-magda ivan-magda added the exam label Jul 4, 2018
@ivan-magda ivan-magda self-assigned this Jul 4, 2018
@kvld kvld added this to the 1.63 milestone Jul 4, 2018
@kvld
Copy link
Contributor

kvld commented Jul 5, 2018

@vanyaland в dev ветке обновился PromiseKit, подмерджи себе

Copy link
Contributor

@kvld kvld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё очень круто! Давай обсудим/поправим и вмерджим.


final class ServiceComponentsAssembly: ServiceComponents {

// MARK: Object Initialization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Когда код достаточно декомпозирован, нужды в MARK: особо нет (к тому же, не все используют XCode). Но это ИМХО и если привык и считаешь, что это нужно – ок.


// MARK: - UserRegistrationService

let userRegistrationService: UserRegistrationService
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мы выносим поля перед конструкторами и остальными методами.

// MARK: UserRegistrationServiceError: Error

enum UserRegistrationServiceError: Error {
case userNotRegistered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если здесь все ошибки будут с префиксом user-, то имеет смысл его опустить.


let stepicsAPI: StepicsAPI

func registerNewUser() -> Promise<User> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Было бы круто шарить этот код с адаптивными, но можно перенести его сюда, а потом заюзать его там.

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз уж начинаем с чистого листа, то стоит подумать перед тем, как юзать сториборды. Возможно, лучше отдельные xibы для каждого контроллера.


// MARK: - UserSubscriptionsService -

protocol UserSubscriptionsService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пока непонятно, зачем размазывать похожую логику на два сервиса.
Если бы у нас была отдельная работа с профилями, то имело бы смысл отделить её от работы с пользователями, но тут, кажется, не планируется ничего кроме отписки.


// MARK: - Instance Properties

var userRegistrationService: UserRegistrationService?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надеюсь, это для дебага и потом здесь добавится отдельная абстракция между view и бизнес логикой.

<key>password</key>
<dict>
<key>id</key>
<string>m3uu1NAGnAGFDHRf4S2Wvg1megAjuqwBsX0OUDru</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это надо закрывать под git-crypt.


let predicate = NSPredicate(format: "isAuthorized == %@", NSNumber(value: true))
let exp = expectation(for: predicate, evaluatedWith: self, handler: nil)
let result = XCTWaiter.wait(for: [exp], timeout: 5.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если пишешь тесты с использованием реального API, то есть два варианта:

  1. замокать API
  2. отделять их от остальных тестов, потому что на CI они могут отвалиться с таймаутом

Copy link
Contributor

@Ostrenkiy Ostrenkiy Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

могут отвалиться

обязательно отвалятся, поправил тебя :trollface:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

прерывная интеграция :trollface:

Copy link
Contributor

@Ostrenkiy Ostrenkiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне нравится. Тему с Assembly слоем (который не является чем-то необходимым, как по мне) хотели имплементить в основном приложении еще прошлой осенью, но после обсуждений и споров решили, что это будет довольно сложно. Классно, если в новом проекте это будет реализовано. Предлагаю с осторожностью относиться к выделению большого количества слоев, так как время на разработку ограничено и излишняя декомпозиция зачастую усложняет восприятие кода.

А вообще Влад очень много полезных комментариев оставил, мне в принципе особо нечего добавить.

@ivan-magda
Copy link
Member Author

@Ostrenkiy, @kvld, спасибо за комментарии. Согласен, возможно я преждевременной оптимизацией занимаюсь и только все усложняю.

@Ostrenkiy
Copy link
Contributor

Тесты не хочется сейчас пока поправлять?

@ivan-magda
Copy link
Member Author

@Ostrenkiy Хочется, нужно еще поразбираться, т.к. с моками и библиотеками для них не знаком.

@ivan-magda
Copy link
Member Author

Отпишусь как будет готово для ревью.

- Delete Main.storyboard file
- Create MainViewController.xib file
- Create UIViewController from nib instantiation extensions
// MARK: Public API

func setup(with window: UIWindow) {
let mainController: MainViewController = MainViewController.fromNib()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MainViewController.fromNib() – это то же самое, что просто MainViewController(), если есть xib с именем MainViewController.xib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ага, открыл для себя магию 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И я

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/*
      The designated initializer. If you subclass UIViewController, you must call the super implementation of this
      method, even if you aren't using a NIB.  (As a convenience, the default init method will do this for you,
      and specify nil for both of this methods arguments.) In the specified NIB, the File's Owner proxy should
      have its class set to your view controller subclass, with the view outlet connected to the main view. If you
      invoke this method with a nil nib name, then this class' -loadView method will attempt to load a NIB whose
      name is the same as your view controller's class. If no such NIB in fact exists then you must either call
      -setView: before -view is invoked, or override the -loadView method to set up your views programatically.
    */
    public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)

@ivan-magda
Copy link
Member Author

@kvld @Ostrenkiy вроде бы все замечания поправил.

@ivan-magda ivan-magda merged commit b54ec3b into dev Jul 6, 2018
@ivan-magda ivan-magda deleted the exam-ege-ru-auth branch July 6, 2018 15:08
@kvld kvld mentioned this pull request Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants