Object Oriented Design

GOOS Book Distilled Part 7

A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code

2 minute read

Let’s start off by taking a closer look at our AuctionSniper. Notice that it implements AuctionEventListener, which means it is now mainly a listener. It listens to AuctionMessageTranslator, and for now, it only implements auctionClosed(). So the next step would naturally be to implement currentPrice(). It is not hard to find out that when receives a PRICE update, the sniper should do 2 things: Sends a higher bid. Display status as BIDDING in UI.

GOOS Book Distilled Part 6

A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code

1 minute read

This is the beginning of Chapter 13 in the book. Well, we have a problem about Main. Let’s see what Main is currently doing for us. It handles UI work. It handles connection to XMPP server. It implements AuctionEventListener. That is AuctionMessageTranslator uses it as a listener. Among the 3 resposibilities, the 3rd one feels not quite right. As the types of messages grows, Main will have to do more and more stuff.

GOOS Book Distilled Part 5

A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code

1 minute read

In previous post, we wrote our first unit test on the AuctionMessageTranslator on how to handle CLOSE message. In this post, we will write another unit test on how to handle PRICE message. This will finally force us to parse the comming messages and look inside them. So when we receive CLOSE message, we call auctionClosed() on AuctionEventListener, when we receive PRICE message, we call currentPrice(int price, int increment). As simple as that.

GOOS Book Distilled Part 4

A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code

1 minute read

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 status LOST. 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.

GOOS Book Distilled Part 3

A follow through of the great book Growing Object-Oriented Software, Guided by Tests with code

1 minute read

In this post, we start our second acceptance test. Sniper makes a higher bid but loses. To be able to implement this, there are 2 fundamental functionalities missing. The fake auction server needs to report price changes. The sniper needs to how to bid according to the price reports. The first is easy, the auction server just sends a PRICE message in the chat. The format of the message is