|
|
|
|
|
by deltaonezero
1462 days ago
|
|
I addressed most of this in our thread. You might as well go back to that. Let me converse with this guy on his own terms. Anyway in response to your reply. It's the same thing. Maybe another renamed example will help you understand. A LoggerSocket class is identical to a WrappedSocket class. It's a wrapper around a socket which is basically similar to a socket itself, so let me call it such. In your method it's: wrappedSocket1 = LoggerSocket()
wrappedSocket2 = LoggerSocket()
doStuff(wrappedSocket: LoggerSocket){
wrappedSocket.log("blah")
}
doStuff(wrappedSocket1)
doStuff(wrappedSocket2)
in my example it's: wrappedsocket1 = Wrapper(Socket())
wrappedsocket2 = Wrapper(Socket())
doStuff(wrappedsocket: Socket){
log(wrappedsocket, "blah")
}
doStuff(wrappedsocket1)
doStuff(wrappedsocket2)
You see the equivalence? The amount of code is the same. The reuseability of the code is not the same as WrappedSocket is more general then LoggerSocket, but BOTH need to be passed everywhere, and editing the core methods/definitions of log() or LoggerSocket has basically the same effect |
|