{"id":15891454,"url":"https://github.com/sewera/product-export-refactoring-kata","last_synced_at":"2025-04-02T17:24:48.682Z","repository":{"id":143187655,"uuid":"613112566","full_name":"sewera/product-export-refactoring-kata","owner":"sewera","description":"Kata for practicing refactoring to Design Patterns, based on Joshua Kerievsky's book","archived":false,"fork":false,"pushed_at":"2023-03-30T17:26:33.000Z","size":185,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T08:12:22.812Z","etag":null,"topics":["design-patterns","kata","refactoring","refactoring-to-pattern"],"latest_commit_sha":null,"homepage":"https://www.sewera.dev/rtp","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sewera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-12T22:44:31.000Z","updated_at":"2023-09-11T09:07:09.000Z","dependencies_parsed_at":"2023-05-12T18:15:51.170Z","dependency_job_id":null,"html_url":"https://github.com/sewera/product-export-refactoring-kata","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sewera%2Fproduct-export-refactoring-kata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sewera%2Fproduct-export-refactoring-kata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sewera%2Fproduct-export-refactoring-kata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sewera%2Fproduct-export-refactoring-kata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sewera","download_url":"https://codeload.github.com/sewera/product-export-refactoring-kata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246857974,"owners_count":20845227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","kata","refactoring","refactoring-to-pattern"],"created_at":"2024-10-06T07:22:14.316Z","updated_at":"2025-04-02T17:24:48.645Z","avatar_url":"https://github.com/sewera.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Product export refactoring kata\n\nCheck out the [resources](https://www.sewera.dev/rtp) for this kata.\n\nThe main book for this kata is [Joshua Kerievsky's \"Refactoring to Patterns\"](https://www.google.com/books/edition/Refactoring_to_Patterns/Oxm8R1dY3RwC).\n\nThis kata is based on Emily Bache's version:\n[emilybache/Product-Export-Refactoring-Kata](https://github.com/emilybache/Product-Export-Refactoring-Kata).\n\n## Tags\n\n1. [t-initial-setup]\n   - This is what we'd find in a legacy code\n   - No tests\n2. [t-tests-in-place]\n   - System is under test\n3. [t-test-for-different-tax-calculation]\n   - Code coverage tool uncovered a different tax calculation algorithm\n4. [t-first-test-refactoring]\n   - Test code should also be refactored\n5. [t-add-lombok-dependency]\n   - We are Java developers of the modern age\n   - Some people will call it poor man's Kotlin. And they'd be right\n6. [t-classes-lombokified-and-simplified]\n   - Look at this removed code, oh my, the [removed code](https://github.com/sewera/product-export-refactoring-kata/compare/t-first-test-refactoring...t-classes-lombokified-and-simplified)!\n7. [t-tax-calculator-under-test]\n   - Tax calculation is tricky and expensive to break\n   - We have to make sure we didn't break anything\n8. [t-ledger-introduced]\n   - We finally got our domain expert\n   - How would you call something that holds a list of orders?\n9. [t-ledger-renamed-to-account]\n   - After further discussions,\n     our domain expert says that it should be an Account.\n10. [t-tax-calculator-removed]\n    - But tax calculation is hard, we don't want to lose it!\n    - Don't worry, now the Account is responsible for it\n11. [t-rtp-price-implicit-leaf-extracted]\n    - Alright, _finally_ we can do the refactoring to a Composite pattern\n    - Look at [one of the commits](https://github.com/sewera/product-export-refactoring-kata/commit/57809d0383f7ee0b4184ded14e138f73bedf95c5)\n      - It's very small\n      - There are a lot of such commits, so Pair Programming may be necessary\n12. [t-strategy-pattern-in-product]\n    - [Introduction](https://github.com/sewera/product-export-refactoring-kata/commit/11b9948368649ef1df9644aa50c13779b2e48737)\n    - [Implementation in StoreEvent](https://github.com/sewera/product-export-refactoring-kata/commit/802b2148a7863c4b4fea237007c80e9d0a4d41b1#diff-2743d87c473294f182a077056669ad94c433d76ba30b63452dcc32f27d6eef23R33-R41)\n    - That strategy pattern came out of nowhere!\n      - But it solved a problem of duplication at that time\n      - It turned out not to be useful later, so it was removed\n13. [t-rtp-refactoring-to-composite-done]\n    - What a journey that was\n    - The design is better, the tests pass after each commit,\n      so we could continuously deliver it to production\n    - Better, shorter functions\n    - But still not declarative enough\n14. [t-domain-objects-moved-to-domain-package]\n    - Wait, why are there xml representations of domain objects\n      in the objects themselves?\n    - You can argue that it _is_ the domain of the project,\n      because the project is solely for exporting XML\n15. [t-rtp-xml-builder-implemented]\n    - Luckily, we've got some spare time,\n      so we'll make the design _even better_\n      by implementing the Builder pattern\n16. [t-rtp-encapsulated-composite-with-builder-in-price]\n    - Now the design better reflects the intent\n    - It's more declarative instead of imperative\n17. [t-rtp-simplify-price-after-encapsulation-with-builder]\n    - Further simplification\n18. [t-rtp-simplify-serialization-in-xml-exporter]\n    - Further deduplication\n19. [t-refactored]\n    - That's much better\n    - Thankfully we did it in Pair Programming,\n      because a [PR for it](https://github.com/sewera/product-export-refactoring-kata/compare/t-initial-setup...t-refactored) would be huge!\n\n[t-initial-setup]: https://github.com/sewera/product-export-refactoring-kata/tree/t-initial-setup\n[t-tests-in-place]: https://github.com/sewera/product-export-refactoring-kata/tree/t-tests-in-place\n[t-test-for-different-tax-calculation]: https://github.com/sewera/product-export-refactoring-kata/tree/t-test-for-different-tax-calculation\n[t-first-test-refactoring]: https://github.com/sewera/product-export-refactoring-kata/tree/t-first-test-refactoring\n[t-add-lombok-dependency]: https://github.com/sewera/product-export-refactoring-kata/tree/t-add-lombok-dependency\n[t-classes-lombokified-and-simplified]: https://github.com/sewera/product-export-refactoring-kata/tree/t-classes-lombokified-and-simplified\n[t-tax-calculator-under-test]: https://github.com/sewera/product-export-refactoring-kata/tree/t-tax-calculator-under-test\n[t-ledger-introduced]: https://github.com/sewera/product-export-refactoring-kata/tree/t-ledger-introduced\n[t-ledger-renamed-to-account]: https://github.com/sewera/product-export-refactoring-kata/tree/t-ledger-renamed-to-account\n[t-tax-calculator-removed]: https://github.com/sewera/product-export-refactoring-kata/tree/t-tax-calculator-removed\n[t-rtp-price-implicit-leaf-extracted]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-price-implicit-leaf-extracted\n[t-strategy-pattern-in-product]: https://github.com/sewera/product-export-refactoring-kata/tree/t-strategy-pattern-in-product\n[t-rtp-refactoring-to-composite-done]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-refactoring-to-composite-done\n[t-domain-objects-moved-to-domain-package]: https://github.com/sewera/product-export-refactoring-kata/tree/t-domain-objects-moved-to-domain-package\n[t-rtp-xml-builder-implemented]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-xml-builder-implemented\n[t-rtp-encapsulated-composite-with-builder-in-price]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-encapsulated-composite-with-builder-in-price\n[t-rtp-simplify-price-after-encapsulation-with-builder]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-simplify-price-after-encapsulation-with-builder\n[t-rtp-simplify-serialization-in-xml-exporter]: https://github.com/sewera/product-export-refactoring-kata/tree/t-rtp-simplify-serialization-in-xml-exporter\n[t-refactored]: https://github.com/sewera/product-export-refactoring-kata/tree/t-refactored\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsewera%2Fproduct-export-refactoring-kata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsewera%2Fproduct-export-refactoring-kata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsewera%2Fproduct-export-refactoring-kata/lists"}