Skip to content

les-tontons-crafters/refactoring-by-example

Repository files navigation

Refactoring By Example

Repository used during Promyze Webinar: "Refactoring by Example". The step-by-step guide is available through git log.

Refactoring by Example cover

Pitch

In our industry, we spend time investigating problems that people have already solved in the past. We've been there, too; finding reliable information is indeed challenging.

During this webinar, we propose showing you practices and insights through a Code Review. We'll work in an OOP language on a codebase you may be familiar with.

The webinar will be a live-coding session where we'll refactor code to improve its readability and maintainability. We will rely on a knowledge base and Promyze to identify areas for improvement.

Everything shown will be applicable during your daily duties on existing codebases.

Guillaume Faas and Yoan Thirion are "Les Tontons Crafters", two passionate software crafters keen to share their knowledge and experiences with the community.

  • Remove unused parameter clientId (automated by IDE)
  • Remove redundant else (automated by IDE)
  • Create value object CreateOrderItem instead of <string, int> (Primitive obsession)
  • Move Order Creation to Factory Method
  • Move logic from Factory method to constructor
  • Prepare OrderItem logic refactoring by extracting logic from UseCase in a mapping method
  • Extract OrderItem Factory method
  • Move factory logic to OrderItem constructor
  • Move Product calculation to Product
  • Move CreateOrderItem to Commands NS
  • Move AddItem logic to Order
  • Move for loop in Order
  • Move OrderItem Factory logic
  • Use ForEach method from LinQ
  • Decompose LinQ for better understanding
  • Use Aggregate to simplify our code. Simplify?
  • Express new expectation from UseCase with a failing test
  • Make it green as fast as possible
  • Refactor: move Exception to Domain
  • Refactor: create a NewWithEither Factory method on Order
  • Refactor: NewWithEither to use the one from OrderItem
  • Refactor: Simplify Order code
  • Clean up: remove all the methods that do not use Either
  • No more exceptions -> only DomainError
  • Use immutable Seq in Order

Promyze CLI

We can now use Promyze CLI to scan our project. Promyze CLI - Tell Don't Ask

Replay

Replay is available here: Refactoring By Example by "Les Tontons Crafters"

Original kata

Full kata's explanations are available here.

About

Repository to demonstrate Xtrem TDD with Promyze

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages