Re: Design by contract and cocoa
Re: Design by contract and cocoa
On 22 Jan 2014, at 17:50, Herman Chan <email@hidden> wrote:
> this seems to be the modernized version of it: https://github.com/brynbellomy/ObjC-DesignByContract
This is indeed a later implementation.
It uses a metamacro approach as used in ReactiveCocoa.
The code also has dependencies on another library that is not included as a submodule so a quick out of the box evaluation isn’t available.
Neither this code nor the original look thread savvy - they both persist the contract state in a static variable.
>
> On 22 Jan 2014, at 12:37, Jens Alfke wrote:
>
>> On Jan 22, 2014, at 8:03 AM, email@hidden wrote:
>>
>>> I know there are some macros available, http://www.roard.com/contracts/, but I haven’t experimented further as yet
>>
>> Interesting. I like the idea of dynamically creating a subclass that wraps the methods to be checked, but I don't like doing it with a bunch of macros. I wonder if there's a cleaner way to do it nowadays using newer Obj-C runtime features. (I'm assuming that code is old since the examples don't use any modern language features like properties.)
The newer implementation eschews the dynamic subclassing approach.
I am also not drawn to the metamacro approach.
The old implementation uses -poseAsClass: and therefore is a dead duck on 64bits.
A runtime approach as you suggest makes sense. KVO style subclassing comes to mind and associated objects could handle any state persistence.
Jonathan
_______________________________________________
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