1- # Test-Driven Development - C# - Chapter 02
1+ # Test-Driven Development - Java - Chapter 02
22
33This solution contains a code for Chapter 2 of the book [ "Test-Driven Development By Example" by
4- Kent Beck] ( https://a.co/d/1sr05eT ) . The code is written in C# and uses the NUnit testing framework for the tests.
4+ Kent Beck] ( https://a.co/d/1sr05eT ) . The code is written in Java and uses the JUnit testing framework for the tests.
55
66For information on how to set up the repository, please see the [ README in the ch00] ( ../ch00/README.md ) folder.
77
@@ -19,13 +19,13 @@ easily understood, maintained, and tested so that any changes can be made with c
1919
2020### Key points from the chapter
2121Kent introduces the concept of the Value Object pattern. In the Chapter 2 implementation, when the ` times() ` method is
22- called, the value of ` Amount ` is changed, hence the title of the chapter - Degenerate Objects. He walks us through how
22+ called, the value of ` amount ` is changed, hence the title of the chapter - Degenerate Objects. He walks us through how
2323he fixes this by returning an immutable value object. The idea is that the ` Dollar ` object should never change its state.
2424Instead, a new object should be returned with the new state.
2525
26- There's a key issue with the implementation in Chapter 2, though. The ` Amount ` member is public and settable. As I
27- explained in the [ README for Chapter 1] ( ../ch01/README.md ) , in C# I would normally implement this as a read-only
28- property (in Java, it would be a getter only) , but I have kept it as a public member to stay true to the book until
26+ There's a key issue with the implementation in Chapter 2, though. The ` amount ` member is public and settable. As I
27+ explained in the [ README for Chapter 1] ( ../ch01/README.md ) , in Java I would normally implement this as a read-only
28+ property with a getter only, but I have kept it as a public member to stay true to the book until
2929we make it private in Chapter 4.
3030
3131Kent also introduces the three strategies for getting to green:
@@ -42,10 +42,11 @@ By the end of the chapter, the TODO list looks like this:
4242- [ ] Money rounding?
4343
4444## Last Update
45- I try and keep this code up to date with the latest versions. I generally wait until a new version of .NET SDK is
46- released and I only update it for Long Term Support (LTS)versions. .NET 8 is the latest LTS version as of this writing.
45+ I try and keep this code up to date with the latest versions. I generally wait until a new version of the JDK or Maven is
46+ released and I only update it for major versions. JDK 25 is the latest version as of this writing, and the POM is set to
47+ use JDK 25 and JUnit 5.13.4.
4748
4849This repository was last updated in September 2025.
49- - .NET SDK version 8
50- - NUnit version 4.4.0
51- - JetBrains Rider version 2025.2.2
50+ - Java JDK version 25
51+ - JUnit version 5.13.4
52+ - JetBrains IntelliJ IDEA Ultimate version 2025.2.2
0 commit comments