Skip to content

Commit

Permalink
[Security Solution][DQD][Tech Debt] Colocate components (elastic#190978)
Browse files Browse the repository at this point in the history
addresses elastic#190964

Second in the series of PRs to address general DQD tech debt. Currently
this PR build on the work of
elastic#190970.

So this PR restructures components to colocate component throughout the
hierarchy.

So instead of:

```bash
root/
  component1/
  childOfComponent1/
  grandChildOfComponent1/
  component2/
  use_hook_used_for_1/
  use_hook_used_for_2/
```

we use:

```bash
root/
  component1/
    hooks/
      use_hook_used_for_1/
    childOfComponent1/
      grandChildOfComponent1/
  component2/
    hooks/
      use_hook_used_for_2/
```

PROs of such scaffold:
- complete and clear hierarchical visibility into component structure of
the entire DQD codebase
- ability to easily introduce and integrate a new change and calculate
its impact on the tree of components
- ability to easily remove colocated functionality without having to
scout through the convoluted DQD code
- clear understanding of where shared code should live as opposed to
know when its shoved into top level by default with other non shared
code
- since nesting too deep has an import name readability tax it forces us
to think about not splitting our components into too many small parts
but rather keep it balanced, as opposed to now where flat structure
incentivizes free and cheap fragmentation as seen with component like
<body />.

CONS:

- import names have too many `../../../../../../../../../`. It is
fixable by ts paths/webpack aliases, but on the other hand especially if
there are many of those it's an indication of potential architectural
smell, that needs to be addressed (which is a PRO).

Imho, overall visibility trumps any cons and facilitates greater ease of
adding new and changing existing functionality with more confidence.

## Before

![image](https://github.com/user-attachments/assets/89062883-c40a-410d-af43-8dbe3e712475)

## After

![image](https://github.com/user-attachments/assets/83e33a85-cf3e-4cb1-a56d-c7f4f27a1f37)
  • Loading branch information
kapral18 authored Aug 26, 2024
1 parent 56730e8 commit dd18bc7
Show file tree
Hide file tree
Showing 213 changed files with 774 additions and 1,227 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit dd18bc7

Please sign in to comment.