Let's say SomeClass
has members Object1
and Object2
and there is a connection between Object1
and Object2
like:
connect(Object1, signal1, Object2, slot1)
After some refactoring Object3
was added to SomeClass
and Object2
was moved to be a member of Object3
, but still exist the need for the connection between Object1
and Object2
.
The communication between Object1
and Object2
will have to go through Object3
now. This means Object3
needs to be modified, adding a pair of signal/slot just to implement that communication between Object1
and Object2
.
This means both Object3
's .h and .cpp will be modified, adding many lines of code to do a thing previously done in just one line.
My lazy side is telling that there is something strange in this story. Is there some way to make that connection more straight forward?
You're encapsulating
Object2
withinObject3
. From the point of view of the user ofObject3
, nothing is changing: there's still only one line of code to set up the connection.Object3
needs an extra slot that forwards to theObject2
instance it now encapsulates. That's one extra line here. And that's it.