-
Notifications
You must be signed in to change notification settings - Fork 11
App loading checks. Realm migration. #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tomholub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments.
While there are a lot of nitpicks (typos and English), there are also some more important questions and requests.
FlowCrypt/Common/Services/Encrypted Storage/EncryptedStorage.swift
Outdated
Show resolved
Hide resolved
FlowCrypt/Common/Services/Encrypted Storage/EncryptedStorage.swift
Outdated
Show resolved
Hide resolved
FlowCrypt/Common/Services/Encrypted Storage/EncryptedStorage.swift
Outdated
Show resolved
Hide resolved
FlowCrypt/Common/Services/Encrypted Storage/EncryptedStorage.swift
Outdated
Show resolved
Hide resolved
FlowCrypt/Common/Services/Encrypted Storage/EncryptedStorage.swift
Outdated
Show resolved
Hide resolved
FlowCrypt/Common/Services/Encrypted Storage/KeyChainService.swift
Outdated
Show resolved
Hide resolved
….com/FlowCrypt/flowcrypt-ios into feature/issue-185-app-loading-checks
….com/FlowCrypt/flowcrypt-ios into feature/issue-185-app-loading-checks
tomholub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. I'll test it and have a second look tomorrow
|
But the tests are failing for some reason @Kharchevskyi |
tomholub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The startupflow is over-engineered.
You have:
- LaunchFlowController
- FlowControllerType
- FlowController
- LaunchContext
- LaunchStepType
- LaunchFlow
- LaunchFlowStepFactory
- CoreLaunchStep
- AuthLaunchStep
- DataBaseLaunchStep
- SessionLaunchStep
- MainLaunchStep
All of this complexity to find out if a few things are as expected. With promises, this could be one class with 6 methods, 5 of them private.
Pseudo-code:
struct LaunchContext {
let window: UIWindow
let aplication: UIApplication
let launchOptions: [UIApplication.LaunchOptionsKey: Any]?
}
class StartupChecks {
public fun runChecks(context: LaunchContext): Promise<void> {
return Promise.all([
this.checkCore(context),
this.checkAuthentication(context),
this.checkDatabase(context),
this.checkSession(context),
this.checkMain(context)
]);
}
private fun checkCore(context: LaunchContext): Promise<void> {
return Promise<void> { _ in
DispatchQueue.promises = .global()
core.startInBackgroundIfNotAlreadyRunning()
}
}
// private fun checkAuthentication() ...
// ...
}It's faster to write, less effort to maintain. The more classes and abstractions you hide a problem behind, the harder it is to solve the problem.
Keep it simple. Simple code is easy to read. Simple code is easy to understand. Simple code is easy to review for security.
I'll refactor it.
|
todo:
|
|
Cannot run UI tests, stuck on #191 |
tomholub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok, but please also review it @Kharchevskyi
|
This solution is not testable. And not scalable. Every of this launch steps ( CoreLaunchStep, AuthLaunchStep,DataBaseLaunchStep,SessionLaunchStep,MainLaunchStep) can be tested separately or mocked for tests. All of them has it's own responsibility. LaunchFlow and LaunchFlowStepFactory create steps, base on a context. In case we receive push notification or open app from deeplink it will create Launchsteps which are responsible for handling events. I don't agree about over-engineering This was scalable, testable and reusable. Now it's only one god object class. |
|
To me, simplicity is more important. I need our code to be easily readable and reviewable, and I need it to be of minimal complexity.
Factory/step approach:
Single class approach:
For our usecase, the tradeoffs are different from a regular app. We need simplicity, readability above everything else.
To handle deeplinks, edit The added complexity comes with a tradeoff, and the tradeoff is not worth it for us. |
|
As for testing, consider this:
I prefer tests that are not tightly coupled to implementation details. Any tests you write that would be testing the factory/step design directly would necessarily be tightly tied to implementation. That is not the kind of tests I want to focus on. |
Add step approach for app loading: close #185
Remove encrypted storage access checks: close #183
Realm Migration: close #190
Minor fix for renewing access token