This is the beginning of Chapter 13 in the book.
Well, we have a problem about
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
AuctionMessageTranslatoruses 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.
Now it is time to create a
AuctionSniper class to make
Main ’s life easier. Now thinking about it, it is quite weird that there is no class named after sniper since our application is call auction sniper . Let’s also create a
SniperListener to put into
AuctionSniper , so that
AuctionSniper does not directly depend on UI.
Now the architecture looks like this:
Pay attention to this structure, something interesting is happening. The shaded components( Chat and Main ) have been pushed to the sides. And what in the middle forms the core of our business logic of the app.