-
Notifications
You must be signed in to change notification settings - Fork 7
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: high level clean code content #41
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 +1,46 @@ | ||
# TBD | ||
### Clean code | ||
|
||
#### Variables | ||
Give meaningful names to variables | ||
|
||
#### Functions | ||
1. Function name should describe what it does. | ||
2. A function should do only one thing. | ||
3. Limit the amount of function parameters, preferably two. if you need more you can send the parameters inside an object. | ||
4. If you find yourself writing the same code more than once, even if its a little bit different, try to generalize it in to a function. | ||
5. Functions should be pure | ||
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. [Sand] 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. Pure function is the life |
||
|
||
#### Classes | ||
|
||
#### React components | ||
1. Make your React component as short as possible | ||
2. Name Your Components Using Standard Naming Conventions | ||
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. [Sand] |
||
3. Reduce the number of props to the minimum | ||
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. [Sand] |
||
4. Put Independent Functions Outside of Your Custom Hooks | ||
5. Split your components to container and presentational components | ||
6. Folderize Your Components | ||
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. [Sand] |
||
|
||
#### DTY | ||
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. You have a typo here :) DTY |
||
DRY is an acronym that stands for "Don’t Repeat Yourself." | ||
If you find yourself writing the same code in different places, consider writing it only once and just reuse it, whether as a function or as a component. | ||
|
||
#### KISS | ||
KISS is an acronym that stands for "Keep it simple stupid." | ||
|
||
#### SOLID | ||
Single Responsibility Principle (SRP) | ||
Open/Closed Principle (OCP) | ||
Liskov Substitution Principle (LSP) | ||
Interface Segregation Principle (ISP) | ||
Dependency Inversion Principle (DIP) | ||
|
||
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. You can add YAGNI as well. Uncle Bob uses it a lot 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. AND I'm not sure SOLID should be here I look at it as something above clean code |
||
|
||
#### Testing | ||
When you write your code, you should write it in a way it would be easy to test it. make your code predictable and testable. | ||
|
||
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. You can write something about TDD or BDD. It goes very well with clean code |
||
#### Error handling | ||
|
||
#### Comments | ||
If you write clean code, it should be self commenting. | ||
|
||
#### Type script |
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.
I think we should have Do's and Don'ts on each topic.