Re: Nullability annotation "best practice"
Re: Nullability annotation "best practice"
- Subject: Re: Nullability annotation "best practice"
- From: Seth Willits <email@hidden>
- Date: Sun, 16 Aug 2015 09:10:45 -0700
Really? This list has no opinions? That's hard to imagine :-)
--
Seth Willits
> On Aug 8, 2015, at 1:15 PM, Seth Willits <email@hidden> wrote:
>
> Let's stipulate that _Nullable and _Nonnull are great to have because they can catch bugs and express API intent better than before, so we want them. The question is where to put them?
>
>
> _Nullable and _Nonnull make perfect sense to specify in the @interface. Since those annotations existing in the @interface will produce applicable warnings and errors in the counterpart @implementation,there's really no _need_ to respecify them in the @implementation of those same methods.
>
> It makes sense for private methods to have nullability annotations for all the same reasons public Now let's assume that private methods aren't specified in any @interface, even the anonymous one. In that case, those methods would naturally have no annotations on their parameters or return values unless they're specified within the @implementation. But specifying them on the private methods in the @implementation while *not* specifying them for the public methods in the @implementation is inconsistent and potentially confusing.
>
>
> So I see two choices here:
>
> 1) Always add nullability annotations, for all methods and properties in both the @interface and @implementation. (Private methods may or may not be declared within @interfaces — but these days I think it's generally not done?)
>
> 2) Only add nullability annotations in the @interface, and always declare private methods within an @interface.
>
>
>
> Is there a third choice I'm not thinking of?
>
>
> Thoughts? I'm curious how Apple is adopting these annotations themselves.
>
>
>
> --
> Seth Willits
>
_______________________________________________
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