Chapter 7. Extending Twootr

The Challenge

Previously, on Twootr, Joe had wanted a modern online communication system to be implemented. The previous chapter presented a potential design for Twootr and the implementation of the core business domain was described, including driving out that design through tests. You learned about some of the design and data modeling decisions involved and how to break down the initial problem and structure your solution. That didn’t cover the whole of the Twootr project, so it’s up to this chapter to complete the narrative.

The Goal

This chapter extends and completes the progress made in the previous chapter by helping you understand about the following topics:

  • Avoiding coupling with the Dependency Inversion Principle and Dependency Injection

  • Persistence with the Repository pattern and the Query Object pattern.

  • A brief introduction to functional programming that will show you how you can make use of the ideas from this in a Java-specific context and a real application.


Since we’re continuing the Twootr project from the previous chapter, it’s probably worth recapping the key concepts in our design at this point. If you’re continuing from the previous chapter in a marathon reading session, then we’re glad you’re enjoying the book, but feel free to skip this section:

  • Twootr is the parent class that instantiates the business logic and orchestrates the system.

  • A Twoot is a single instance of a message broadcast by a user in our ...

Get Real-World Software Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.