Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 46 additions & 1 deletion design/Frontend-Design.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# TBD
### Clean code

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.


#### 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Sand]
Maybe we should add a small explanation or a reference to what pure means..

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Sand]
Whats the Standard we're using for naming conventions?

3. Reduce the number of props to the minimum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Sand]
Should we talk about prop-types here or that's not a part of clean code?

4. Put Independent Functions Outside of Your Custom Hooks
5. Split your components to container and presentational components
6. Folderize Your Components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Sand]
Maybe putting an example of this will be good :)


#### DTY
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add YAGNI as well. Uncle Bob uses it a lot

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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