[swift-evolution] [Draft] Allow declaration of abstract functions and properties on classes
Vanderlei Martinelli
vmartinelli at alecrim.com
Fri Feb 26 10:38:44 CST 2016
Currently I have in a private framework a class named
`AccountAuthorizationController` with subclasses like
`OAuthAccountAuthorizationController`,
`OAuth2AccountAuthorizationController` and
`WebFormAccountAuthorizationController` and so on.
In the root "abstract" class I have methods without implementation where I
have to use `fatalError()` to ensure that they will never been called. I
cannot prevent the framework user to instantiate the
`AccountAuthorizationController`, however.
Look that this is only one example. I have other cases as well when I'd
like to have abstract classes and abstract methods.
I know that structs and protocols are "elegant, simple and powerful" (as
they seem to be all new frameworks and languages that pop up every day on
the Internet) and the arguments in favor of composition rather than
inheritance. But I still would like to take advantage of the decades of
available knowledge in object orientation in my projects.
+1 for abstract classes and abstract methods.
-Van
On Fri, Feb 26, 2016 at 12:46 PM, Evan Maloney via swift-evolution <
swift-evolution at swift.org> wrote:
> > Well not exactly, if you want the same behaviors in subclasses of
> UIViewController and UITableViewController :
> > - with protocols + extensions, you write in once and apply it to each of
> your subclasses
> > - with abstract classes you have to write 2 abstract classes, one for
> direct UIViewController subclasses, one for UITableViewController subclasses
>
> That's a problem with class hierarchies in general, not with abstract
> classes.
>
> You can use the same argument to call for the removal of classes from
> Swift, which is why I think the fundamental question is, are classes
> intended to be first-class citizens in Swift?
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160226/d4441baa/attachment.html>
More information about the swift-evolution
mailing list