Skip to content

Commit

Permalink
Included more pages
Browse files Browse the repository at this point in the history
  • Loading branch information
zhendrikse committed Feb 11, 2025
1 parent 191156d commit d9758b1
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 11 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/dojo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ e.g. Python for the first time, and they managed pretty soon pretty well.

- [Tuple's pair-programming guide](https://tuple.app/pair-programming-guide/scientific-research-into-pair-programming)
- [The many sides of pair programming and the importance of deliberate practice of it](https://www.linkedin.com/pulse/many-sides-pair-programming-importance-deliberate-practice-paul-cox/)


{% include share_buttons.html %}
3 changes: 0 additions & 3 deletions docs/header.md

This file was deleted.

50 changes: 42 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{% include breadcrumbs.html %}

<blockquote>
Of the four project development variables - scope, cost, time and quality - quality isn't really a free variable. The only possible values are "excellent" and "insanely excellent", depending on whether lives are at stake.
Kent Beck . &mdash;
Of the four project development variables &mdash;
scope, cost, time and quality &mdash; quality isn't really a free variable.
The only possible values are "excellent" and "insanely excellent",
depending on whether lives are at stake. &mdash;
<a href="https://en.wikipedia.org/wiki/Kent_Beck">Kent Beck</a>
</blockquote><br/>

# Test-driven development (TDD)
## Test-driven development (TDD)
<div class="header_line"><br/></div>

<div class="row">
Expand All @@ -19,16 +21,18 @@ Kent Beck . &mdash;
</figure>
</div>
<div class="column" style="background-color:#004444;">
<h2><a href="legacy/index.html">TDD &amp; legacy code</a></h2>
<h2><a href="devops/index.html">TDD &amp; DevOps</a></h2>
<figure>
<a href="legacy/index.html">
<img alt="Nicolas Carlo" src="https://github.com/zhendrikse/tdd/blob/master/presentations/images/legacy_code.png?raw=true"/>
<a href="devops/index.html">
<img alt="Dave Farley" src="https://github.com/zhendrikse/tdd/blob/master/assets/organizational-health.png?raw=true"/>
</a>&nbsp;&nbsp;&nbsp;
</figure>
</div>
</div>

# Coding dojo &amp; coding katas
<p style="clear: both;"></p>

## Coding dojo &amp; coding katas
<div class="header_line"><br/></div>

<div class="row">
Expand All @@ -44,8 +48,38 @@ Kent Beck . &mdash;
<h2><a href="katas/index.html">Coding katas</a></h2>
<figure>
<a href="katas/index.html">
<img alt="Dojo" src="https://github.com/zhendrikse/tdd/blob/master/assets/kata.png?raw=true"/>
<img alt="Dojo" width="80%" src="https://github.com/zhendrikse/tdd/blob/master/assets/kata.png?raw=true"/>
</a>&nbsp;&nbsp;&nbsp;
</figure>
</div>
</div>

<p style="clear: both;"></p>


## Related topics
<div class="header_line"><br/></div>

<div class="row">
<div class="column" style="background-color:#004444;">
<h2><a href="portsadapters/index.html">Ports &amp; adapters</a></h2>
<figure>
<a href="portsadapters/index.html">
<img alt="Uncle Bob" src="https://github.com/zhendrikse/tdd/blob/master/assets/uncle-bob.png?raw=true"/>
</a>&nbsp;&nbsp;&nbsp;
</figure>
</div>
<div class="column" style="background-color:#004444;">
<h2><a href="legacy/index.html">Legacy code</a></h2>
<figure>
<a href="legacy/index.html">
<img alt="Nicolas Carlo" src="https://github.com/zhendrikse/tdd/blob/master/presentations/images/legacy_code.png?raw=true"/>
</a>&nbsp;&nbsp;&nbsp;
</figure>
</div>
</div>

<p style="clear: both;"></p>


{% include share_buttons.html %}
2 changes: 2 additions & 0 deletions docs/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ before we had a test for it. Remember that this spoils the whole idea of TDD!
- [Catalog of refactorings](https://refactoring.com/catalog/) by Martin Fowler
- [Refactoring Guru](https://refactoring.guru/) makes it easy for you to discover everything you need to know about refactoring, design patterns, SOLID principles, and other smart programming topics
- [Branching by abstraction](https://www.martinfowler.com/bliki/BranchByAbstraction.html)

{% include share_buttons.html %}
2 changes: 2 additions & 0 deletions docs/katas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ the way Clojure chunks lazy sequences).
- [A curated list of programming katas](https://hackmd.io/@pierodibello/A-curated-list-of-programming-kata#A-curated-list-of-programming-kata)
- [Awesome katas](https://github.com/gamontal/awesome-katas#readme)
- [Kata-Log](https://kata-log.rocks/)

{% include share_buttons.html %}
2 changes: 2 additions & 0 deletions docs/legacy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ as you may sometimes encounter code without (sufficient) tests, but the code [re
- [Refactoring... but at scale!](https://understandlegacycode.com/blog/key-points-of-refactoring-at-scale/)
- [When should you stop refactoring Legacy Code?](https://understandlegacycode.com/blog/when-should-you-stop-refactoring-legacy-code/)


{% include share_buttons.html %}
87 changes: 87 additions & 0 deletions docs/portsandadapters/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{% include breadcrumbs.html %}

# Communication with the outside world
<div class="header_line"><br/></div>

This page is about the hexagonal architecture.

![Ports and adapters](https://github.com/zhendrikse/tdd/raw/master/assets/ports-and-adapters-architecture.svg?sanitize=true)

The above picture has been taken from
[Growing Object-Oriented Software Guided by Tests](http://www.growing-object-oriented-software.com/figures.html)
by Steve Freeman and Nat Pryce ([Creative Commons License](http://creativecommons.org/licenses/by-sa/4.0/)).

The central idea here is to move the dependencies to external systems
to the boundaries of your domain model. By defining ports (realized as interfaces)
and adapters (implementations of these interfaces that connect to the
external system), we

- Prevent externalities leaking into our system, such as relational data models,
JSON and/or XML message structures, and so forth.
- Make it easy to plug in fakes and stubs into our ports, which in turn keeps
our tests independent of the external systems and guarantees that they remain fast!

Since some of the coding katas in this repository specifically address
this topic, this page discusses the required concepts that are common
to all these katas. These concepts all fall under the umbrella of what's
generally known as the
[Hexagonal Architecture](http://alistair.cockburn.us/Hexagonal+architecture)
(a.k.a. Ports and Adapters). Uncle Bob elaborated on this concept and coined it the
[clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).

## TDD and communication with external systems

A question that is often raised is: How do I practice TDD when I
have to deal with the dependencies of my system to the outside world?
Examples of such dependencies are databases, file systems, networks, etc.
So isn't it inevitable then that I eventually have to include
tests involving these external systems in my tests and as
a consequence my tests (gradually) become slow?

Many people are inclined to introduce mocks into their tests at
this point, but apparently these people haven't heard of the
[don't mock what you don't own](http://jmock.org/oopsla2004.pdf)
principle. A good but somewhat long read about this topic is also
Martin Fowler's well-known
[mocks aren't stubs](https://martinfowler.com/articles/mocksArentStubs.html).

So what do we do then when mocks are not meant to be used for this purpose?
The answer is to apply dependency
inversion and to use so-called ports and adapters.

![Hexagonal architecture](https://github.com/zhendrikse/tdd/raw/master/assets/hex-arch.png)

- [Dependency Inversion](https://stackify.com/dependency-inversion-principle/)
is the last of the five well-known
[SOLID](http://blog.cleancoder.com/uncle-bob/2020/10/18/Solid-Relevance.html)
principles. In a nutshell, it boils down to dictating to the outside world
what the data should look like, as opposed to letting the outside world
determine your (object) model. The idea is to think in terms of the
domain model first and to make the
[primary and secondary actors](https://codesoapbox.dev/ports-adapters-aka-hexagonal-architecture-explained/)
comply with the ubiquitous language established by our domain model.
This implies e.g. that no field names or data models from external systems
should be able to "leak" into our domain model!

- [Ports and adapters](https://alistair.cockburn.us/hexagonal-architecture/):
as is explained in
[this article](https://codesoapbox.dev/ports-adapters-aka-hexagonal-architecture-explained/),
"The main principle of the Ports &amp; Adapters architecture is to have
inputs and outputs on the edges of technology-agnostic code".


![Hexagonal architecture](https://github.com/zhendrikse/tdd/raw/master/assets/hex-arch-unit.png)

## References

- A good read is the
[Ports and adapters as they should be](https://medium.com/wearewaes/ports-and-adapters-as-they-should-be-6aa5da8893b)
post by Felipe Flores.
By realizing the ports &amp; adapters by using
[the adapter pattern](https://refactoring.guru/design-patterns/adapter)
(which is polymorphic by definition), we keep our system under
development testable all the time.
- Another good website with project structure and code examples is [Hexagonal Me](https://jmgarridopaz.github.io/).
- Nicolas Carlo on separating infrastructure (tests) from domain (tests): [If you mock, are you even testing?](https://understandlegacycode.com/blog/if-you-mock-are-you-even-testing/)

{% include share_buttons.html %}

0 comments on commit d9758b1

Please # to comment.