Re: Nullability annotation "best practice"
Re: Nullability annotation "best practice"
- Subject: Re: Nullability annotation "best practice"
- From: Seth Willits <email@hidden>
- Date: Tue, 18 Aug 2015 13:42:10 -0700
On Aug 16, 2015, at 11:13 AM, Kevin Meaney <email@hidden> wrote:
> I’ve annotated the public methods of the API of a framework and though I haven’t yet I will annotate internal methods and functions as well.
>
> I found a small number of issues where my thinking had not been clear, and that having to stop and consider what was intended when annotating the public API for nullability exposed my lack of clarity. I did not have any recorded bugs in this case but I could see how the API could be used that would result in bugs, crashing or otherwise.
I added annotations to both the public and private sides of a core framework that's about 17,000 lines of code, and I had the same experiences. On both sides, while 97% of it was clear cut, there was a small number of cases where I wasn't really sure what the answer to nullability and knock on effects was. If I say this public function returns non-null, how sure of that am I really? In a few places I really had to go digging and verify that every step along the way ensured that result.
Like you, I don't believe I caught any current bugs, but it clarified my thinking, and showed potential edge cases in the future which could have resulted in problems that now would be caught by the compiler.
Although it was tedious to add those annotations and validate them (it only took half a day or so), I feel better for having done it.
--
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