Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Improving code
quality
@jsuchal
Issues
1. Doing the wrong thing
2. Excessive coupling
3. Mutable state
4. Premature abstraction
5. Edge conditions
Tips
&
Tricks
Outside-in development
● Start at the very top
○ discover dependencies
○ avoids unit interface incompatibility problem
○ h...
TDD
● Acceptance (end-to-end) tests
○ start here!
○ nonexhaustive (avoid exponential blowup)
● Unit tests
○ a design tool
...
Immutable OO
● Best trick for maintainable code, by far!
● All fields immutable
● Mental trick
○ obj.method(*args) == meth...
Smell-Driven Development
● private / protected
○ missing collaborator, extract & inject
● not using all fields
○ class doi...
Smell-Driven Development (2)
● Law of Demeter (one dot rule)
○ getters are ok!
● Avoid global constants
○ a.k.a. implicit ...
Premature abstraction
● “Third time is the charm.”
● KISS
● YAGNI
Tools
● rubocop
○ the code style grammar nazi
● reek
○ code smell detection
● mutant
○ mutation testing
● mbj/devtools
○ t...
Improving code quality
Improving code quality
Improving code quality
Improving code quality
Improving code quality
Prochain SlideShare
Chargement dans…5
×

Improving code quality

810 vues

Publié le

Tips & Tricks for improving code quality

Publié dans : Technologie
  • Soyez le premier à commenter

Improving code quality

  1. 1. Improving code quality @jsuchal
  2. 2. Issues 1. Doing the wrong thing 2. Excessive coupling 3. Mutable state 4. Premature abstraction 5. Edge conditions
  3. 3. Tips & Tricks
  4. 4. Outside-in development ● Start at the very top ○ discover dependencies ○ avoids unit interface incompatibility problem ○ how would I test this? ● Programming by wishful thinking ○ design usage, review/discuss, implement later, refactor a lot later ○ do / refactor mode
  5. 5. TDD ● Acceptance (end-to-end) tests ○ start here! ○ nonexhaustive (avoid exponential blowup) ● Unit tests ○ a design tool ○ a testing tool
  6. 6. Immutable OO ● Best trick for maintainable code, by far! ● All fields immutable ● Mental trick ○ obj.method(*args) == method(Class obj, *args) ● Code smells are obvious ● Temporal coupling is impossible ● OOP finally makes sense
  7. 7. Smell-Driven Development ● private / protected ○ missing collaborator, extract & inject ● not using all fields ○ class doing too much, split ● prefixes ○ missing abstraction, extract & inject ● returning self or void ○ mutable state, avoid! ● duplicated logic in parent method ○ inject listener/responder
  8. 8. Smell-Driven Development (2) ● Law of Demeter (one dot rule) ○ getters are ok! ● Avoid global constants ○ a.k.a. implicit dependencies ○ yes, class name is a constant ● Data Clump, Feature Envy ● Test smells
  9. 9. Premature abstraction ● “Third time is the charm.” ● KISS ● YAGNI
  10. 10. Tools ● rubocop ○ the code style grammar nazi ● reek ○ code smell detection ● mutant ○ mutation testing ● mbj/devtools ○ the CI task!

×