note: This is of couse about software-architecture/design-principles, but as no architecture is completely detached from its language, please note that the language i am using is C++.
I am using an API, with a debug-layer that lets you give names to API-specific objects, so that readable debug-output is generated from within the API.
Assume that i want to give the name "ANiceObject" to an object A
Because that object is relatively "low-level", it is part of an abstraction B in my code.
But to name it, i need access to the object itself.
I see the following options:
- provide getter inside
Bto accessA(breaks encapsulation) - provide interface in
Bto nameA(Bshouldn't have that responsibility)
Apart from this problem, i also want this debug-logic to be as separate as possible from the production-logic.
Has anyone some guidance, or ideas on how to achieve the naming of A for debug-purposes without breaking my architecture, and cluttering my code?
B, each with a differently named objectAinside. Note that, by naming, i refer to letting the API give a name toA, which is an opaque handle to me. I am not referring to giving a string-member-variable or sth. like that. Let me know if things are unclear in my question, and i will edit to clarify.