[SERVER-29864] Clarify/revisit how IDL-generated classes fit into larger C++ classes Created: 26/Jun/17 Updated: 08/Jan/24 |
|
| Status: | Open |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 3.5.9 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kaloian Manassiev | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Service Arch
|
||||||||||||
| Participants: | |||||||||||||
| Description |
|
The LogicalSessionId class inherits from Logical_session_id so that it can make use of the IDL-generated class' getters, setters, and parsing logic. The LogicalSessionId class is intended to be a value-add on top of the IDL-generated parsing code. This inheritance however makes it difficult to write code at the boundary between initialization and construction, because that requires casting from one type to the other. We should revisit and clarify the way that C++ classes are meant to incorporate or compose with IDL-generated classes, and develop clear methods and guidelines for how to do that in a way that is more straightforward. We could consider recommending factory functions and static getters rather than using inheritance in cases like these. |
| Comments |
| Comment by Lauren Lewis (Inactive) [ 24/Feb/22 ] |
|
We haven’t heard back from you for at least one calendar year, so this issue is being closed. If this is still an issue for you, please provide additional information and we will reopen the ticket. |
| Comment by Mark Benvenuto [ 31/Jul/17 ] |
|
mira.carey@mongodb.com, gabriel.russell, and I have had a few ideas: 1. Add an ability to declare a class to derive from for Curiously recurring template pattern |
| Comment by Kaloian Manassiev [ 07/Jul/17 ] |
|
I don't have a good answer for what the ideal solution should be, but the two patterns that I encountered while working with IDL generated classes were:
The problems that arise with inheritance is that vectors of these objects are not castable to each other for example. |