Chapter 8. Design how-to: date and time handling

 

This chapter covers:

  • 8.1 Why object-oriented date and time handling? 153
  • 8.2 Finding the right abstractions 155
  • 8.3 Advanced object construction 158
  • 8.4 Large-scale structure 163
  • 8.5 Using value objects 173
  • 8.6 Implementing the basic classes 176
  • 8.7 Summary 186

Applying object-oriented principles and patterns tends to be more art than science, more improvisation than ritual, more understanding than precise skill. At worst, it’s like movie weddings. Real weddings are notoriously predictable and strictly organized. But in movie weddings, shock and awe is the rule: someone makes a blunder like saying “your awful wedded wife,” the bride or the groom runs away, the wedding guests start fighting, or worse.

We want to avoid making software that acts like a runaway bride. Therefore, we want to learn to handle all the discrepancies and unexpected twists. It comes with experience; you have to try it out, look at examples in a real context, and think long and hard about them. How does everything relate? What are the alternatives? What are the consequences of these alternatives? To help us do this, we’ll study a well-known domain that provides a more realistic context for some of the principles and patterns.

8.1. Why object-oriented date and time handling?

8.2. Finding the right abstractions

8.3. Advanced object construction

8.4. Large-scale structure

8.5. Using value objects

8.6. Implementing the basic classes

8.7. Summary