Sunday, September 11, 2016

Code smells - small research

Sept. 11, 2016

Small research about Common code smells

Warm up the topic:
Benefits:
1. Reduce stress to write and also maintain the code
2. Build a good habit to write/ refactor code/ design concern/ thinking logically,
3. Amazon leadership principle: internal customer support -> external support, high standard, genesis of AWS - from infrastructure support to AWS

https://www.amazon.jobs/principles

Insist on the Highest Standards
Leaders have relentlessly high standards

Train to be a leader.
End of warm up



On Sept. 12 evening, spent 2 hours reading code smells -
Read the boook "refactor "
http://goo.gl/8r2AJO

Code smells:
Refactoring: Improving the design of existing code

Chapter 3: Bad smells in code:
Duplicate code   ()
Long method      ()
Large Class
Long Parameter Lsit
Divergent change
Shortgun surgery
Feature Envy
Data Clumps
Primitive Obsession
Switch Statements
Parallel Inheritance Hierarchies
Lazy Class
Speculative Generality
Temporary Field
Message Chains
Middle Man
Inappropriate Intimacy
Alternative Classes with Different Interfaces
Incomplete Library Class
Data Class
Refused Bequest
Comments

End of 2 hours of reading - have the above notes

Read the article:

1.https://en.wikipedia.org/wiki/Code_smell

Julia's Notes

Application-level smells:
1. Duplicate code
2. Contrived complexity

Class-level smells:
1. Large class
2. Feature envy
3. Refused bequest  (Liskov substitution principle)
4. Lazy clss/ freeloader
5. Excessive use of literals
6. Cyclomatic complexity
7. Downcasting
8. Orphan variable or constant class

Method-level smells
1. Too many parameters
2. Long method
3. Excessively long identifiers
4. Excessively short identifiers
5. Excessive return of data

2. https://en.wikipedia.org/wiki/Cyclomatic_complexity

a positive correlation between cyclomatic complexity and defects: functions and methods that have the highest complexity

tend to also contain the most defects

3.Static program analysis
https://en.wikipedia.org/wiki/Static_program_analysis

Blog reading:
Leetcode 247: Segment Tree Query (II)
Leetcode 247 Segment Tree Query (II)

http://www.tangjikai.com/algorithms/leetcode-247-segment-tree-query-ii

Will come back to work on the algorithm.

Julia's most favorite concept - Cyclomatic complexity - No more long function!

No comments:

Post a Comment