forked from smartdevicelink/sdl_evolution
-
Notifications
You must be signed in to change notification settings - Fork 0
Simplifying structure of the class ApplicationManagerImpl #13
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
Open
VadymLuchko
wants to merge
3
commits into
master
Choose a base branch
from
refactor/Simplifying_structure_of_the_class_ApplicationManagerImpl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
222 changes: 222 additions & 0 deletions
222
proposals/____-Simplifying-structure-of-the-class-ApplicationManagerImpl.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| # Simplifying the structure of the class `ApplicationManagerImpl` | ||
|
|
||
|
|
||
| ## Introduction | ||
|
|
||
| Concentration of various functionality within one class violates the single responsibility principle and makes it difficult to work with the class file. | ||
| `ApplicationManagerImpl.cc` contains more then 5000 lines of code that solve various problems and can be thematically categorized into separate classes. | ||
|
|
||
| ## Motivation | ||
|
|
||
| Working with the ApplicationManagerImpl would be more convenient if some of the specific functionality would be moved into separate classes and these classes would be combined in a composition in the ApplicationManagerImpl. | ||
| With this approach, the ApplicationManagerImpl structure would be simpler and clearer. | ||
|
|
||
|
|
||
| ## Proposed solution | ||
|
|
||
| As mentioned in the previous section, we could move some parts of `ApplicationManagerImpl.cc` to more approprite places. | ||
|
|
||
|
|
||
| Proposed edits : | ||
|
|
||
|
|
||
| Move next functions to utils | ||
|
|
||
| ``` | ||
| get_rand_from_range() | ||
| DirectoryTypeToString() | ||
| InitDirectory() | ||
| IsReadWriteAllowed() | ||
| SaveBinary() | ||
| IsSOStructValid() | ||
| ConvertSOtoMessage() | ||
| GenerateGrammarID() | ||
| ``` | ||
|
|
||
|
|
||
| Change next predicates to lambda functions where it is used, which will allow us to reduce the amount of code and make the code more expressive | ||
|
|
||
| ``` | ||
| device_id_comparator() | ||
| PolicyAppIdComparator() | ||
| ActiveAppPredicate() | ||
| FullOrLimitedAppPredicate() | ||
| LimitedMediaAppPredicate() | ||
| LimitedNaviAppPredicate() | ||
| LimitedVoiceAppPredicate() | ||
| NaviAppPredicate() | ||
| LimitedMobileProjectionPredicate() | ||
| MobileProjectionPredicate() | ||
| IsApplication() | ||
| MobileAppIdPredicate() | ||
| TakeDeviceHandle() | ||
| ``` | ||
|
|
||
|
|
||
| Move methods to new sub class `ApplicationDataProvider` since they are closely related | ||
| ``` | ||
| applications() | ||
| pending_applications() | ||
| reregister_applications() | ||
| application() | ||
| application_by_hmi_app() | ||
| application_by_policy_id() | ||
| pending_application_by_policy_id() | ||
| application_by_name() | ||
| reregister_application_by_policy_id() | ||
| active_application() | ||
| get_full_or_limited_application() | ||
| get_limited_media_application() | ||
| get_limited_navi_application() | ||
| get_limited_voice_application() | ||
| applications_with_navi() | ||
| get_limited_mobile_projection_application() | ||
| applications_with_mobile_projection() | ||
| applications_by_button() | ||
| applications_by_name() | ||
|
|
||
| OnApplicationRegistered() | ||
| OnApplicationSwitched() | ||
| RegisterApplication() | ||
| FinalizeAppRegistration() | ||
| ActivateApplication() | ||
| CreateApplications() | ||
| set_application_id() | ||
| SetUnregisterAllApplicationsReason() | ||
| UnregisterAllApplications() | ||
| RemoveAppsWaitingForRegistration() | ||
| UnregisterApplication() | ||
| OnAppUnauthorized() | ||
| GetHashedAppID() | ||
| ProcessApp() | ||
| IsApplicationForbidden() | ||
| GetAvailableSpaceForApp() | ||
| OnApplicationListUpdateTimer() | ||
| EraseAppFromReconnectionList() | ||
| AddAppToRegisteredAppList() | ||
| ``` | ||
|
|
||
|
|
||
| Move methods to new class `GlobalPropertiesHandler` | ||
|
|
||
| ``` | ||
| OnTimerSendTTSGlobalProperties() | ||
| AddAppToTTSGlobalPropertiesList() | ||
| RemoveAppFromTTSGlobalPropertiesList() | ||
| ResetGlobalProperties() | ||
| ResetAllApplicationGlobalProperties() | ||
| CreateAllAppGlobalPropsIDList() | ||
| ClearTTSGlobalPropertiesList() | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
| Move methods to separate plugin `waypoints_plugin` | ||
| ``` | ||
| IsAppSubscribedForWayPoints() | ||
| SubscribeAppForWayPoints() | ||
| UnsubscribeAppFromWayPoints() | ||
| SaveWayPointsMessage() | ||
| IsAnyAppSubscribedForWayPoints() | ||
| GetAppsSubscribedForWayPoints() | ||
| ``` | ||
|
|
||
| Move methods to new class `StreamingHandler` | ||
| ``` | ||
| CanAppStream() | ||
| ForbidStreaming() | ||
| OnAppStreaming() | ||
| ProcessOnDataStreamingNotification() | ||
| StartEndStreamTimer() | ||
| EndNaviStreaming() | ||
| DisallowStreaming() | ||
| AllowStreaming() | ||
| StartNaviService() | ||
| StopNaviService() | ||
| OnServiceStartedCallback() | ||
| OnServiceEndedCallback() | ||
| ProcessServiceStatusUpdate() | ||
| HandleRejectedServiceStatus() | ||
| EndNaviServices() | ||
| ``` | ||
|
|
||
| Move methods to new class `HmiHandler` | ||
| ``` | ||
| IsHmiLevelFullAllowed() | ||
| OnHMIReady() | ||
| GetDefaultHmiLevel() | ||
| GenerateNewHMIAppID() | ||
| RemoveHMIFakeParameters() | ||
| hmi_so_factory() | ||
| hmi_capabilities() | ||
| HMIStateAllowsStreaming() | ||
| OnHMIStateChanged() | ||
| ProcessPostponedMessages() | ||
| IsHMICooperating() | ||
| SetHMICooperating() | ||
| CompareAppHMIType() | ||
| OnUpdateHMIAppType() | ||
| ChangeAppsHMILevel() | ||
| GetNextHMICorrelationID() | ||
| ``` | ||
|
|
||
| Move methods to new class `MobileHandler` | ||
| ``` | ||
| GetNextMobileCorrelationID() | ||
| GetCorrectMobileIDFromMessage() | ||
| mobile_so_factory() | ||
| ``` | ||
|
|
||
|
|
||
| Move methods to new class `DevicesHandler` | ||
| ``` | ||
| ConnectToDevice() | ||
| OnWebEngineDeviceCreated() | ||
| GetDeviceName() | ||
| GetDeviceTransportType() | ||
| RemoveDevice() | ||
| OnDeviceSwitchingStart() | ||
| OnDeviceSwitchingFinish() | ||
| GetUserConsentForDevice() | ||
| OnDeviceListUpdated() | ||
| ``` | ||
|
|
||
|
|
||
| Move methods to new class `SecurityHandler` | ||
| ``` | ||
| OnHandshakeDone() | ||
| OnPTUFailed() | ||
| OnGetSystemTimeFailed() | ||
| OnCertificateUpdateRequired() | ||
| GetPolicyCertificateData() | ||
| GetHandshakeContext() | ||
| OnCertDecryptFinished() | ||
| OnCertDecryptFailed() | ||
| ``` | ||
|
|
||
|
|
||
| Move methods to new class `ApplicationsHandler` | ||
| ``` | ||
|
|
||
| ``` | ||
|
|
||
| After these edits, the ApplicationManagerImpl class will be engaged in organizing the interaction of the new classes described above | ||
|
|
||
| ![img][uml-diagram] | ||
|
|
||
|
|
||
|
|
||
| ## Potential downsides | ||
|
|
||
| New files for each new class will be created and added to repository | ||
|
|
||
|
|
||
| ## Impact on existing code | ||
| Only ApplicationManagerImpl class of SDL Core will be impacted. | ||
|
|
||
|
|
||
| ## Alternatives considered | ||
| Leave ApplicationManagerImpl as is | ||
|
|
||
|
|
||
| [uml-diagram]: ../assets/proposals/appManagerImpl_refactor/app_manager_uml.png | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@VadymLuchko I think this should be a part of
ApplicationDataProvideras it works with the same collectionThere 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.
edited in 5df5aab