GOOS Book Distilled Part 4
A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code
This is a series of blog posts going through the great book Growing Object Oriented Software Guided By Tests, typing in code chapter by chapter, trying to add some of my own understanding where things may not be easy to grasp in the book. I highly recommand you get a copy of the book and follow along with me. Happy coding.
Let’s recap what our sniper can do by now, which is not much.
-
Start UI window. Show
JOINING
status. -
Join auction. Which means connect to XMPP server, login as sniper and listening to the auction’s chat. Send the
JOIN
message to the chat. -
When receives a
CLOSE
message(the only type of message now), show statusLOST
.
The 3rd one looks a bit naive. On the high level, the sniper should be able to receive different types of messages and act on them accordingly, in other words, translate messages into actions. So we created a AuctionMessageTranslator
. It also takes in a AuctionEventListener
, which represents what actions can be triggered.
Now we start to see that we are gradually putting business logic into POJOs that are more detached to the framework. This also means that it’s easier to write unit tests for them.
So we write the first test for the translator: notifiesAuctionClosedWhenCloseMessageReceived
.
This wraps up this post. In next post, we will work on more message types. Stay tuned.
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Email