GOOS Book Distilled Part 6

综合编程 2018-02-18 阅读原文

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.

  1. It handles UI work.
  2. It handles connection to XMPP server.
  3. 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.

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.

Source code

责编内容by:Guowei Lv 【阅读原文】。感谢您的支持!


Sort properties in java Is there a way to sort the Properties object in java? I have the string which ...
WebView面试详解 一、WebView 常见的一些坑 1. webview 在android api16以及之前版本的安全漏洞,该漏洞是因为程序没有正确的限...
Apache PDFBox 2.0.9 发布,Java 的 PDF 处理类库... Apache PDFBox 2.0.9 已发布,Apache PDFBox 库是一个开源的用于处理 PDF 文档的 Java 工具。 这是针对 2.0.8...
A functional approach to dependency injection in J... SuperKleisliIsFantasticFrameworksAreAtrocious A functional approach to depende...
Pipeline Input Stream Is Locked I am trying to write the data using the pipe input streams. But from thread d...