Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
1CONFIDENTIAL
Caring About Code
Quality
Tamas Korozsi
2015
2CONFIDENTIAL
ME
3CONFIDENTIAL
Clean Code: A Handbook of Agile Software Craftsmanship
by Robert C. Martin
The Book
4CONFIDENTIAL
Does it work?
What is Clean Code?
Does it scale?
Is it esthetic?
Is it maintainable?
Is it testable?
Is it s...
5CONFIDENTIAL
• Focused
• Single-minded attitude
• Undistracted and unpolluted
• Readable, simple and direct
• Compact and...
6CONFIDENTIAL
• Subjective
• If you can’t measure, you can’t improve
• Identify what matters
• Defend and justify decision...
7CONFIDENTIAL
Cyclomatic complexity
public void foo() {
if (c1) {
f1();
} else {
f2();
}
if (c2) {
f3();
} else {
f4();
}
...
8CONFIDENTIAL
Always leave the campground
cleaner than you found it.
The Boy Scout Rule
9CONFIDENTIAL
• Came from city crime researchers
• A broken window will trigger a building into a
smashed and abandoned de...
10CONFIDENTIAL
Composed method example
public void add(Object element) {
if (!readOnly) {
int newSize = size + 1;
if (newS...
11CONFIDENTIAL
Implementation patterns
12CONFIDENTIAL
• Divide your program into methods that perform one identifiable task
• Keep all of the operation in a meth...
13CONFIDENTIAL
Composed method example
public void add(Object element) {
if (!isReadOnly()) {
if (atCapacity()) {
grow();
...
14CONFIDENTIAL
• Instant feedback
• Allows you to make changes to code quickly
• Help you understand the design of the cod...
15CONFIDENTIAL
• Whether the unit you're testing should be
isolated from its collaborators
• Mockist approach
– Isolate fr...
16CONFIDENTIAL
• Change Risk Analysis and Prediction
• Help you identify code that might be particularly difficult to
unde...
17CONFIDENTIAL
• Don’t build complex machines
• Don’t build frameworks
• Make the software so simple that there are
obviou...
18CONFIDENTIAL
• Avoid Cargo cult programming
• Question authority
• Accept feedback and give feedback
Angry monkeys exper...
19CONFIDENTIAL
EPAM Academy
Aniko_b
20CONFIDENTIAL
TAMAS_KOROZSI@EPAM.COM
THANK YOU FOR ATTENTION!
QUESTIONS?
Nächste SlideShare
Wird geladen in …5
×
Nächste SlideShare
What to Upload to SlideShare
Weiter
Herunterladen, um offline zu lesen und im Vollbildmodus anzuzeigen.

0

Teilen

Herunterladen, um offline zu lesen

clean code - uncle bob

Herunterladen, um offline zu lesen

clean code - uncle bob - summary PowerPoint pptx filetype

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Ähnliche Hörbücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen
  • Gehören Sie zu den Ersten, denen das gefällt!

clean code - uncle bob

  1. 1. 1CONFIDENTIAL Caring About Code Quality Tamas Korozsi 2015
  2. 2. 2CONFIDENTIAL ME
  3. 3. 3CONFIDENTIAL Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin The Book
  4. 4. 4CONFIDENTIAL Does it work? What is Clean Code? Does it scale? Is it esthetic? Is it maintainable? Is it testable? Is it short? Is it clever? Does it have explanatory comments? Is it easy to understand? Is it well-structured? Is it object-oriented?
  5. 5. 5CONFIDENTIAL • Focused • Single-minded attitude • Undistracted and unpolluted • Readable, simple and direct • Compact and literate • Contains only what is necessary • Makes it easy for other developers to enhance it • Tests should be also clean • Looks like it’s author cares • Contains no duplicates • Foundations are established on tiny abstractions What is Clean Code after all?
  6. 6. 6CONFIDENTIAL • Subjective • If you can’t measure, you can’t improve • Identify what matters • Defend and justify decisions. The need for measurement
  7. 7. 7CONFIDENTIAL Cyclomatic complexity public void foo() { if (c1) { f1(); } else { f2(); } if (c2) { f3(); } else { f4(); } } • Upper bound for the number of test cases that are necessary to achieve a complete branch coverage • Lower bound for the number of paths through the control flow graph • Desirable value: below 10 Cyclomatic complexity: 3
  8. 8. 8CONFIDENTIAL Always leave the campground cleaner than you found it. The Boy Scout Rule
  9. 9. 9CONFIDENTIAL • Came from city crime researchers • A broken window will trigger a building into a smashed and abandoned derelict • So does the software Broken Window Theory
  10. 10. 10CONFIDENTIAL Composed method example public void add(Object element) { if (!readOnly) { int newSize = size + 1; if (newSize > elements.length) { Object[] newElements = new Object[elements.length + 10]; for (int index = 0; index < size; index++) { newElements[index] = elements[index]; elements = newElements; } } elements[size++] = element; } }
  11. 11. 11CONFIDENTIAL Implementation patterns
  12. 12. 12CONFIDENTIAL • Divide your program into methods that perform one identifiable task • Keep all of the operation in a method at a same level of abstraction • This will naturally result in programs with many small methods, each few lines long. Composed method pattern by Kent Beck
  13. 13. 13CONFIDENTIAL Composed method example public void add(Object element) { if (!isReadOnly()) { if (atCapacity()) { grow(); } addElement(element); } }
  14. 14. 14CONFIDENTIAL • Instant feedback • Allows you to make changes to code quickly • Help you understand the design of the code you are working on • Writing testable code helps to achieve better code quality • Unit tests are a form of sample code • Test-first forces you to plan before you code Advantages of Unit tests
  15. 15. 15CONFIDENTIAL • Whether the unit you're testing should be isolated from its collaborators • Mockist approach – Isolate from dependencies – More flexible in what you can test • Classic approach – No attempt to isolate unless communicating with the collaborator is awkward – Less brittle tests Unit tests collaborator isolation
  16. 16. 16CONFIDENTIAL • Change Risk Analysis and Prediction • Help you identify code that might be particularly difficult to understand, test, or maintain • 𝐶𝑅𝐴𝑃 𝑚 = cycl_comp(m)2 ∗ 1 − 𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒 3 + cycl_comp(m) • A method with a CRAP score over 30 is considered unacceptable C.R.A.P. metric Cyclomatic Complexity Coverage required 0 – 5 0% 10 42% 15 57% 20 71% 25 80% 30 100% 31+ Not possible
  17. 17. 17CONFIDENTIAL • Don’t build complex machines • Don’t build frameworks • Make the software so simple that there are obviously no deficiencies • Keep it simple, stupid (KISS) Rube Goldberg Machines
  18. 18. 18CONFIDENTIAL • Avoid Cargo cult programming • Question authority • Accept feedback and give feedback Angry monkeys experiment
  19. 19. 19CONFIDENTIAL EPAM Academy Aniko_b
  20. 20. 20CONFIDENTIAL TAMAS_KOROZSI@EPAM.COM THANK YOU FOR ATTENTION! QUESTIONS?

clean code - uncle bob - summary PowerPoint pptx filetype

Aufrufe

Aufrufe insgesamt

56

Auf Slideshare

0

Aus Einbettungen

0

Anzahl der Einbettungen

0

Befehle

Downloads

0

Geteilt

0

Kommentare

0

Likes

0

×