Slide 1

Slide 1 text

CLEAN CODE GROWING HEALTHY SYSTEMS / Michael Hamrah @mhamrah

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Time it takes to add one line of code: 10 seconds Time it takes to add one file: 30 seconds? Time it takes to understand 500 lines of code? Time to understand 500 files?

Slide 4

Slide 4 text

WHAT TO DO? CLEAN/ONION ARCHITECTURE DATA, CONTEXT AND INTERACTION EVOLVING CODE THROUGH TESTS

Slide 5

Slide 5 text

BUT FIRST, EXECUTION CONTEXT Do you understand what is happening? Not a language problem: Ruby, Go, Js, Scala. All readable. Does your friend understand what is happening? Would a stranger understand what is happening?

Slide 6

Slide 6 text

CLEAN ARCHITECTURE

Slide 7

Slide 7 text

AKA ONION ARCHITECTURE Control Dependencies Db is not the center of the app Framework is not the center of the app Separate Concerns Focus on important code

Slide 8

Slide 8 text

/ Clean Architecture Onion Architecture

Slide 9

Slide 9 text

HOW EASY IS IT TO REPLACE X? THE DEPENDENCY RULE: SOURCE CODE DEPENDENCIES CAN ONLY POINT INWARDS. The name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes, variables or any other named software entity.

Slide 10

Slide 10 text

LEAN ARCHITECTURE ( A M A Z O N ) DCI: DATA, CONTEXT, INTERACTION ( W I K I P E D I A) Split what a system is (data) from what a system does (interaction) Context is the glue Think of a waiter in a restaurant

Slide 11

Slide 11 text

IF A TEST NEVER FAILED, DOES IT EVER REALLY PASS? IT'S ABOUT THE WHY AND THE HOW Are you forcing a puzzle piece?

Slide 12

Slide 12 text

TEST FIRST: EVOLVE YOUR CODE What do you need to happen? How easy is it to make it happen? Tell a story Look for smells! Refactor!

Slide 13

Slide 13 text

IN SUMMARY Conforming to these simple rules is not hard, and will save you a lot of headaches going forward. By separating the software into layers, and conforming to The Dependency Rule, you will create a system that is intrinsically testable, with all the benefits that implies. When any of the external parts of the system become obsolete, like the database, or the web framework, you can replace those obsolete elements with a minimum of fuss.