Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Effortless Software Development

Anna Filina
November 10, 2019

Effortless Software Development

Software development can be an eternal struggle, or it can be code that pretty much writes itself. In this talk, we’ll look at how simple acceptance tests and a few diagrams help us dive right into the code, which we in turn outline using DDD, This allows us to have a clean and testable design without worrying about implementation details. Code can be then implemented without developers worrying about stepping on each others’ toes, while still be confident that everything will work once put together. Discover how my team can build features faster than the client can sign them off.

Anna Filina

November 10, 2019
Tweet

More Decks by Anna Filina

Other Decks in Programming

Transcript

  1. Waiting for user tests Merge conflicts Adding missing requirements Waiting

    on someone else Someone you never heard of
 disagrees with requirements Redesign Despair Writing code Figuring out requirements 50-page document Approving the document Figuring out... 20 levels of inheritance 800-line methods 6 levels of nested IFs What does $array2 contain? How to unit- test this thing? Is this var null right now?
  2. Anna Filina ‣ Coding since 1997. ‣ PHP since 2003.

    ‣ Legacy archaeologist. ‣ Test automation. ‣ Talks and workshops. ‣ YouTube videos.
  3. Solution ‣ Get a product owner (not a committee). ‣

    Direct & quick access to product owner. ‣ Should not have other roles in the org. ‣ Should not delegate questions. ‣ Communicate requirements using acceptance tests.
  4. Scenario: User can subscribe with a credit card Given I

    selected a membership option When I enter valid credit card details Then I should see a payment receipt
  5. Scenario: Discounts are matched based on current date Given A

    5% discount "FIVE" active on 2019-01-01 through 2019-01-31 And A 10% discount "TEN" active on 2019-02-01 through 2019-02-28 And The current date is 2019-01-15 When I check for discounts Then The "FIVE" discount should be found
  6. I select a membership option I enter valid credit card

    details I should see a payment receipt Requirements Use cases (scenarios)
  7. API UI User Select membership Order Create order {product_code} Payment

    screen Enter payment details Receipt {confirmation_num} Finalize order {card} Receipt
  8. API UI User Select membership Order Create order {product_code} Payment

    screen Enter payment details Receipt {confirmation_num} Finalize order {card} Receipt
  9. final class CreateOrderHandler { public function handle(Request $request) : Response

    { $productCode = new ProductCode( $request->getAttribute('product_code') ); $product = $this->products->getByCode($productCode); $order = $this->orders->create($product); return new JsonResponse([ 'order' => $order->toArray(), ]); } }
  10. final class CreateOrderHandler { public function handle(Request $request) : Response

    { $productCode = new ProductCode( $request->getAttribute('product_code') ); $product = $this->products->getByCode($productCode); $order = $this->orders->create($product); return new JsonResponse([ 'order' => $order->toArray(), ]); } }
  11. interface ProductStorage { public function getByCode(ProductCode $code) : Product; }

    interface OrderStorage { public function create(Product $product) : Order; }
  12. interface ProductStorage { public function getByCode(ProductCode $code) : Product; }

    interface OrderStorage { public function create(Product $product) : Order }
  13. final class ProductCode { private $code; public function __construct(string $code)

    { Assert::that($code) ->notBlank() ->maxLength(15); $this->code = $code; } public function getCode() : string { return $this->code; } }
  14. Mob Programming ‣ Handler: 13 lines. ‣ Interfaces: 8 lines.

    ‣ Value objects: 46 lines. ‣ = 67 ‣ Shared vision.
  15. Split the Work ‣ Test handler. ‣ Implement interfaces +

    tests. ‣ Implement validation of value object + tests. ‣ Implement steps of acceptance tests.
  16. @wip Scenario: User can subscribe with a credit card Given

    I selected a membership option When I enter valid credit card details Then I should see a payment receipt Call 1 Call 2 Assertion
  17. Lessons Learned ‣ Code is living documentation. ‣ Don't try

    to figure everything out upfront (unknowns). ‣ Mistakes are normal (fail fast). ‣ Work together more often.
  18. Further Topics ‣ Domain-driven development. ‣ Test-driven development. ‣ Behavior-driven

    design. ‣ SOLID principles. ‣ Clean code. ‣ Extreme programming. ‣ Scrum.