The preceding code reorganization gives us a solid, logical place to create the new Abstract Base Class (ABC) that we mentioned earlier. The goal of this new ABC is to require derived classes to be able to provide a message-data-ready data structure that can be passed to DaemonMessage as the data argument in its __init__ method, both streamlining the process of creating a message for any given object that needs one, and allowing the code for that process to exist as part of the individual data object classes themselves. In keeping with the naming convention that's evolved in the code so far, this would probably be best written as an instance method named to_message_data. Another option considered was
Preparation for object transactions
Get Hands-On Software Engineering with Python 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.