Skip navigation.
 
mlRe: ADC Core Data article
FROM : Paul Szego
DATE : Fri Apr 08 11:50:41 2005

On 06/04/2005, at 7:52 PM, mmalcolm crawford wrote:

>
> On Apr 5, 2005, at 11:22 PM, Paul Szego wrote:
>

>>
>> On 06/04/2005, at 2:48 PM, Will Mason wrote:

>>>> On the other hand, if you don't need all these services and just aim
>>>> for persistence, CoreData aren't what you need: just use an
>>>> NSArchiver, and you get the support for any NSObject :))
>>>>

>>>
>>> No, you don't. An object can be archived (sent to/read from an
>>> NSCoder)
>>> only if it adopts the NSCoding protocol.
>>>

>>
>> A similar approach for CoreData would be better. Having a base class
>> that implements this for free is a good thing, as long as that's not
>> the only way to do it. Hopefully you wont be forced to extend a
>> specific base class - that's just bad design.
>>

> The article is very clear:
> "By default, the class used is NSManagedObject, but the class may be
> either NSManagedObject or a subclass thereof."
>
> If Core Data only addressed object persistence, then it might be
> argued that this would be poor design.


My comments were about the design of the framework, and whether it's a
persistence framework or logging framework or anything doesn't really
matter. The same principles still apply.

>  As noted earlier, however, it also solves a much more difficult
> problem, and one that really only affects data objects.  Given the
> functionality that's provided for free, requiring that your model
> classes inherit (ultimately) from NSManagedObject instead of NSObject
> does not seem too onerous (I suspect in most cases this will simply
> involve adding 7 characters to your declaration...).


Forcing someone to extend a specific base class in order to work with a
framework is fundamentally flawed, and not necessary.

You are putting serious constraints on the class hierarchy. What if
I've already got a rich class hierarchy, and only want some of my
existing classes to be persistent? What if I want my class to use two
frameworks, that both insist I extend their base class? What if I'm
already extending another base class of my own? If my object model is
one of the problem domain, I shouldn't be constrained about how to
implement it just because of a particular technology choice.

And there is no need to force such constraints onto developers. It's
bad design of the framework. It's already widely accepted to be a key
selection criteria for persistence frameworks in other development
environments, and most often solutions that force this approach on the
developer are dismissed out of hand for anything but the most trivial
of applications.

The issue here is inheritance. It shouldn't be used as a shortcut for
getting utility function for free. If we're talking about model class
(in the MVC sense) then it should be used to model "IS-A" relationships
that exist between the things these classes represent in the underlying
problem domain.

It's also so very simple to avoid. Just define a protocol for the
responsibilities of a class wanting to participate in whatever this
framework offers. You can always provide a "helper" base class for the
simple (perhaps even majority) case where that's suitable. Then if you
can't or don't want to extend the base class you're not dead in the
water.

>
> Indeed it's reasonable to argue that putting all the functionality of
> a model object into the root class would be bad design.  It would add
> an unnecessary overhead to all the other system classes, from views to
> controls to strings (which don't need to know what entity they
> represent or what context they belong to(*))...


I didn't suggest that it belongs in NSObject. I also believe that would
be a mistake.

Paul.

Related mailsAuthorDate
mlADC Core Data article mmalcolm crawford Apr 5, 17:33
mlRe: ADC Core Data article Philip Mötteli Apr 5, 23:49
mlRe: ADC Core Data article Guy English Apr 6, 00:29
mlRe: ADC Core Data article Scott Stevenson Apr 6, 01:14
mlRe: ADC Core Data article Dustin Voss Apr 6, 02:18
mlRe: ADC Core Data article James Duncan David… Apr 6, 02:27
mlRe: ADC Core Data article Jake Macmullin Apr 6, 02:31
mlRe: ADC Core Data article John C. Randolph Apr 6, 02:55
mlRe: ADC Core Data article James Duncan David… Apr 6, 03:01
mlRe: ADC Core Data article Ondra Cada Apr 6, 04:04
mlRe: ADC Core Data article Will Mason Apr 6, 04:48
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:05
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:06
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 07:46
mlRe: ADC Core Data article Paul Szego Apr 6, 08:22
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 09:52
mlRe: ADC Core Data article ?????Andre? Apr 6, 09:55
mlRe: ADC Core Data article Ondra Cada Apr 6, 12:21
mlRe: ADC Core Data article oplus Apr 6, 12:32
mlRe: ADC Core Data article Mont Rothstein Apr 6, 12:36
mlRe: ADC Core Data article Philip Mötteli Apr 6, 14:47
mlRe: ADC Core Data article Scott Stevenson Apr 6, 18:00
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 18:39
mlRe: ADC Core Data article Nat! Apr 6, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 23:47
mlRe: ADC Core Data article Timothy Reaves Apr 7, 00:25
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 00:50
mlRe: ADC Core Data article Shawn Erickson Apr 7, 01:05
mlRe: ADC Core Data article James Duncan David… Apr 7, 01:28
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:37
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:41
mlRe: ADC Core Data article Scott Stevenson Apr 7, 06:59
mlRe: ADC Core Data article Philip Mötteli Apr 7, 08:32
mlRe: ADC Core Data article Marcel Weiher Apr 7, 11:59
mlRe: ADC Core Data article Charlton Wilbur Apr 7, 15:11
mlRe: ADC Core Data article Mike Ferris Apr 7, 16:53
mlRe: ADC Core Data article Marcel Weiher Apr 7, 16:55
mlRe: ADC Core Data article Marco Scheurer Apr 7, 17:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 19:13
mlRe: ADC Core Data article Scott Stevenson Apr 7, 19:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 21:03
mlRe: ADC Core Data article Mike R. Manzano Apr 7, 21:21
mlRe: ADC Core Data article Timothy Reaves Apr 7, 22:03
mlRe: ADC Core Data article Evan DiBiase Apr 7, 22:28
mlconstraint satisfaction (was: ADC Core Data article) Marcel Weiher Apr 7, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 23:05
mlRe: Re: ADC Core Data article ttempel Apr 8, 01:50
mlRe: ADC Core Data article Paul Szego Apr 8, 11:50
mlRe: ADC Core Data article Johnny Deadman Apr 8, 14:10
mlRe: ADC Core Data article Philippe Mougin Apr 8, 16:52
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:07
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:17
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:28
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:32
mlRe: ADC Core Data article John Brownlow Apr 8, 17:47
mlRe: ADC Core Data article Charlton Wilbur Apr 8, 18:34
mlRe: ADC Core Data article Scott Stevenson Apr 8, 18:43
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 19:03
mlRe: ADC Core Data article Philippe Mougin Apr 8, 20:37
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:46
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:48
mlRe: ADC Core Data article Evan DiBiase Apr 8, 22:16
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 22:30
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 23:13
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:20
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:46
mlRe: ADC Core Data article Scott Ellsworth Apr 9, 09:39
mlRe: ADC Core Data article Marcel Weiher Apr 9, 09:44
mlRe: ADC Core Data article Byron Ellis Apr 9, 10:37
mlRe: ADC Core Data article Marcel Weiher Apr 9, 14:03
mlRe: ADC Core Data article Charlton Wilbur Apr 9, 16:01
mlRe: ADC Core Data article ?????Andre? Apr 9, 18:08
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:24
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:27
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:06
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:16
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:38
mlRe: ADC Core Data article ?????Andre? Apr 10, 01:03
mlRe: ADC Core Data article Charlton Wilbur Apr 10, 01:13
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 01:53
mlRe: ADC Core Data article Scott Stevenson Apr 10, 01:58
mlRe: ADC Core Data article Todd Blanchard Apr 10, 08:32
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 08:52
mlModerator: EOT Re: ADC Core Data article mmalcolm crawford Apr 10, 09:25
mlRe: ADC Core Data article PA Apr 10, 12:08
mlRe: ADC Core Data article mmalcolm crawford Apr 30, 10:18