> Background:
> Just a little background into what I was trying to achieve (I could be wrong):
> 
> - I have a set of classes C1, C2, C3 which has a lot of common code
> 
> - I would like to build something that can be reused without exposing the 
> implementation details. (I can subclass but would expose the underlying 
> functions, same applies to protocol as well)
> 
> - I thought I would build helper class / struct which would contain the 
> common code. I can make the helper a private property so that the functions 
> wouldn’t be exposed to the instances of C1, C2, C3. In order to achieve that 
> I had to pass some functions from C1 into the Helper struct.
> 
> Question 2:
> - Is this problem (hiding implementation details) normally tackled using 
> Helper class (or struct) or is there a more better approach ?

Usually, as long as the protocol doesn't reference self or have associated 
types, I would use a protocol as the "abstract" type and then you could 
implement it in either a class or struct.

Joanna

--
Joanna Carter
Carter Consulting

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to