Last active
July 23, 2018 14:22
-
-
Save zero88/88b5a638fc9005576c903f4153b94d45 to your computer and use it in GitHub Desktop.
Revisions
-
Zero-88 revised this gist
Jul 23, 2018 . 1 changed file with 32 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,32 @@ # Clean Code **Code for human not machines** Code is clean if anyone in team can understand, easy to read and enhance by other developer instead of origin author. Code clean is readability, flexibility, extensibility, maintainability. Bullet points: 1. Keep code simple stupid. - Reduce complexity algorithm as muc as possible. - Return code early to keep `code_indent <= 3` - Avoid negative condition 2. Follow one consistence coding standard for **_team_**. 3. Naming convention - Variable/function/class/module name is meaningful, explanatory. - Name can be long if it is public, short name is acceptable if it is private. - Function/ Method name is Verb, meanwhile variable/class/module is Noun. - Extract magic number to constants. 4. Don't repeat yourself: No duplicate code. 5. Single responsibility - Single module/package contains a set of similar classes, that represents one campaign concept. - Single class wraps a set of similar functions, that represents one duty of campaign. - Single function covers one and only one purpose, and do it well. 6. No god class, long method, many arguments/parameters in method - Class: `line_of_code < 1000` - Method: `line_of_code < 50` - Method parameters: `total_parameter < 5` 7. Catching and logging exception even if exception is thrown in silent. 8. Loose coupling: each software layer (presentation layer/business layer/persistence layer/database layer, etc.) or each part in MVC communicates to each other via abstract interface instead of concreate. 9. Code modular: seprate functionality into independent and interchangeble module. Use more `composite/component` pattern instead of `inheritance`. -
Zero-88 created this gist
Jul 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # Clean Code