Содержание
- 2. Tell me, what is a clean code for you?
- 3. for (i = 0;i 0 && char_code
- 4. void CEquation::trio(double array[][rt+1],double alfa[][rt+1]) { for (int L = 0; L
- 5. Good vs Bad
- 6. How to write beautiful code There are two parts to learning craftsmanship: knowledge and work. You
- 7. 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software
- 8. Why do we see a bad code? Time: I don't have a time We never seem
- 10. Naming is important
- 11. The name should represent the developer’s idea int d; // time from beginning int elapsedTimeInDays; int
- 12. The name should represent the developer’s idea public List getThem() { List list1 = new ArrayList
- 13. The name should represent the developer’s idea public List getFlaggedCells() { List flaggedCells = new ArrayList
- 14. Use meaningful difference public static void copyChars(char a1[], char a2[]) { for (int i = 0;
- 15. Use meaningful names private Date genymdhms; private Date modymdhms; private final String pszqint = "102"; VS
- 16. Use searchable names #define CFT_CNT 13 #define SSIM_CLS_CNT 4096 #define PX_BUFF_CNT 10000
- 17. Class names Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account,
- 18. Method names Methods should have verb or verb phrase names like postPayment deletePage, or save. Accessors,
- 19. Method Names Should Say What They Do Date newDate = date.add(5); Would you expect this to
- 20. One function – one operation Functions (aka methods)
- 21. Functions (aka methods)
- 22. F1:Too Many Arguments Functions should have a small number of arguments. No argument is best, followed
- 23. F3: Flag Arguments Boolean arguments loudly declare that the function does more than one thing. They
- 24. I’ll leave the project when complete all my technical debt
- 25. Code review Each team member review the code and writing comments/recomendations It’s a primary responsibility of
- 26. Comments C1: Inappropriate Information Change histories(?) Authors(?) Date of last update(?) C2: Obsolete Comment It is
- 27. Comments C3. Redundant Comment Don’t comment what a code does – I can read the code
- 28. Comments C4: Poorly Written Comment Comments should say Why or purpose, not how C5: Commented-Out Code
- 29. General G1: Multiple Languages in One Source File a Java source file might contain snippets of
- 30. General G5: Duplication Every time you see duplication in the code, it represents a missed opportunity
- 31. General G5: Duplication (cont) modules that have similar algorithms, but that don’t share similar lines of
- 32. General G6: Code at Wrong Level of Abstraction Good software design requires that we separate concepts
- 33. General G7: Base Classes Depending on Their Derivatives The most common reason for partitioning concepts into
- 34. General G9: Dead Code You find it in the body of an if statement that checks
- 35. General G11: Inconsistency If you do something a certain way, do all similar things in the
- 36. General G23: Prefer Polymorphism to If/Else or Switch/Case “ONE SWITCH” rule: There may be no more
- 37. General G28: Encapsulate Conditionals if (shouldBeDeleted(timer)) is preferable to if (timer.hasExpired() && !timer.isRecurrent())
- 38. General G29: Avoid Negative Conditionals if (buffer.shouldCompact()) is preferable to if (!buffer.shouldNotCompact())
- 39. General G35: Keep Configurable Data at High Levels
- 40. One more Clear, not Clever Don’t be clever, instead be clear “I never make stupid mistakes.
- 41. What is “code smell”? Wiki say: In computer programming, code smell is any symptom in the
- 42. The most “popular” code smells
- 43. Bad vs. Clean code What is the clean code? What is the bad code? Characteristics of
- 44. What do you know now? What is Code Smell It’s a feeling or sense that something
- 45. How to improve code quality?
- 47. Скачать презентацию