-
Notifications
You must be signed in to change notification settings - Fork 174
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
feat: update decomposition cheatsheet #697
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,19 +1,31 @@ | ||||||
--- | ||||||
# sidebar_position: 3 | ||||||
unlisted: true | ||||||
--- | ||||||
|
||||||
# Decomposition cheatsheet | ||||||
|
||||||
Use this as a quick reference when you're deciding how to decompose your UI. PDF versions are also available below, so you can print it out and keep one under your pillow. | ||||||
|
||||||
## Choosing a layer | ||||||
## Decomposition by necessity {#decomposition-by-necessity} | ||||||
It is a common mistake to assign separate slides to the part of the code that is not reused anywhere. | ||||||
This mistake creates several problems at once: | ||||||
- The codebase becomes more disjointed, making the code harder to navigate. | ||||||
- A person reading your code, seeing that a slice is not part of the page, may begin to question whether they are breaking part of the display by changing that slice. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: it's not clear to me what "display" is suggestion:
Suggested change
|
||||||
- This is a violation of basic principles such as [KISS](https://en.wikipedia.org/wiki/KISS_principle) and [Occam's Razor](https://en.wikipedia.org/wiki/Occam%27s_razor). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (non-blocking): I'd say it's more of a violation of YAGNI (you ain't gonna need it) |
||||||
|
||||||
It can be avoided by following a simple rule: **"Parts of code that are not reused anywhere should be where they are used"**. | ||||||
|
||||||
For example, we have a component that contains a block of information about a user. This component is only used on the profile page, so it should stay on the profile page. | ||||||
|
||||||
If you are sure that your slice will be used in more than one place, you can use the note below. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion:
Suggested change
|
||||||
|
||||||
## Choosing a layer {#choosing-a-layer} | ||||||
|
||||||
[Download PDF](/files/choosing-a-layer-en.pdf) | ||||||
|
||||||
![Definitions of all layers and self-check questions](/img/choosing-a-layer-en.jpg) | ||||||
|
||||||
## Examples | ||||||
## Examples {#examples} | ||||||
|
||||||
### Tweet | ||||||
|
||||||
|
@@ -32,3 +44,4 @@ Use this as a quick reference when you're deciding how to decompose your UI. PDF | |||||
- [(Thread) About the difference between features and entities](https://t.me/feature_sliced/3776) | ||||||
- [(Thread) About the difference between things and entities (2)](https://t.me/feature_sliced/3248) | ||||||
- [(Thread) About the application of criteria for decomposition](https://t.me/feature_sliced/3833) | ||||||
- [(Thread) About decomposition by necessity](https://t.me/feature_sliced/1/106360) |
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.
issue: typo, and also the phrasing is a bit unclear
suggestion:
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.
also, it's not always a mistake to extract code into a slice when it's not reused. Sometimes, large chunks of code can be extracted into layers below to decrease the size of a page, it's just that these decisions need to be taken consciously and only when the size of the page is a problem (usually it isn't)