Re: Init in Swift
Re: Init in Swift
- Subject: Re: Init in Swift
- From: Quincey Morris <email@hidden>
- Date: Tue, 06 Sep 2016 20:49:34 -0700
- Feedback-id: 167118m:167118agrif8a:167118sNOOIIdVds:SMTPCORP
On Sep 6, 2016, at 17:17 , Gerriet M. Denkmann <email@hidden> wrote:
>
> But what to do about localConstantDependingOnSuper?
Now you’re moving the goal posts. :) I said:
> assuming the places of definition aren’t more complicated than in your code
and you’re making it more complicated. Anyway, this particular example is fairly easily solved by declaring “localConstantDependingOnSuper” as ‘private(set)’.
> I do not think this would work for me. There are several subclasses and the superclass contains lots of functions (some of which are overwritten by subclasses).
> If the superclass becomes a protocol then all this code had to be duplicated in each subclass.
>
>
> Another problem:
> Super → SubA and SubB.
> SubA → SubA1 and SubA2
> SubB → SubB1 and SubB2
>
> Both SubA1 and SubB1 have identical functions. As have SubA2 and SubB2.
> Multiple inheritance would be a solution here; but neither Objective-C nor Swift can do this (and I don’t like C++).
There’s not necessarily a straightforward conversion from subclassing to protocol composition. It usually takes some fundamental re-thinking of your approach to to the problem.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden