-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Architectural problems and anti-patterns in our code. #9050
Comments
Great idea, @cjcenizal. I'll dump a list in here as a starting point. Maybe we can move that into the issue's main body after sorting through it. Behaviour and data are attached directly to
|
Directives trigger actions implicitly by modifying scope dataWhat is the Problem? User intent is translated into system actions in at least three (inconsistent) ways. One of them is to modify an object available on the scope in the expectation that some other part of the system will watch that object and react to the change correctly. This has several drawbacks:
Possible Solution Model user interactions as explicit function calls that push the side effects to the very boundary of the system. These functions can be injected into the directive as an attribute (via an isolate scope binding). Example Occurrences |
Business logic is scattered across many controllersWhat is the Problem? Many changes to the application state are defined inline in the controllers. This has the effect that some controllers are extremely large (~500 lines in example 1) and hard to read. Any inclusion of state change logic in the controllers limits the possibility of reuse by other parts of Kibana or its plugins, thereby reducing consistency. In the same way, documenting and testing this functionality might be more difficult, inhibiting the malleability of the codebase. Possible Solution Encapsulate common business logic in state changes in functions or services and limit code in the controllers to performing the minimal adaption to view-specific data structures and functions. Example Occurrences |
I'm trying to not restate too many of the SOLID principles and other general best practices for large codebases here. Many of the fundamentals like function/argument naming and function purity could keep us busy for a while. 😉 |
Decouple code from Angular as much as possible
|
Unintuitive Folder StructureCurrently it is difficult to quickly know where to look for certain files, or logic. For example, we have:
The angular style guide (see #9049) has some suggestions around folder and file structure |
Define clearer Top Nav "menu" interfaceThe systemCurrently, apps configure the Top Nav by setting a configuration array on the scope, commonly called // app_example.js
$scope.topNavMenu = [{
key: 'fooDropdown',
description: 'Foo',
template: require('path/to/foo_dropdown.html')
}];
$scope.opts = {
sayHello: () => console.log('Hello, world'),
}; The app's root template instantiates the Top Nav and passes in the configuration array: <!-- app_example.html -->
<kbn-top-nav name="dashboard" config="topNavMenu">
<!-- Other top nav stuff -->
</kbn-top-nav> The kbnTopNav controller contains logic for building the Top Nav menu buttons and applying this configuration to them, as well as logic for displaying the relevant dropdown for the selected menu button. The templates that are used to build the Top Nav have access to the inherited scope: <!-- foo_dropdown.html -->
<button ng-click="opts.sayHello()">Say Hello</button> Problems
SolutionIdeally, we'll use a single interface for instantiating the top nav, and this will be the only interface we use to explicitly provide dependencies. |
Closing this as all of these issues will be addressed by moving to React. |
Goal
Let's use this issue as a meta issue to track fundamental software design issues within Kibana.
The text was updated successfully, but these errors were encountered: