Improving Code Quality - Session 41: The Architecture Design Process
Key point
This introduces a design approach that reduces complexity through MessageModelRepository in a structure where different DAOs are used per message type.
Details
In messaging send/receive applications, the data model and creation logic can vary depending on the message type (text, image, external resource, etc.). In particular, for cases like ExternalResource where the existing model and logic are completely different, a separate DAO must be implemented to handle it.
However, having client code directly select and use multiple DAOs according to message type makes the code complex and risks introducing bugs.
To solve this, a MessageModelRepository is introduced, designed so that the appropriate DAO for a given messageId is automatically selected through each DAO's supports function.
By applying this approach, the client side no longer needs to know about the internal DAOs and can obtain a MessageModel in a consistent way through the MessageModelRepository.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.