Re: What's the argument aTableView used for?
Re: What's the argument aTableView used for?
- Subject: Re: What's the argument aTableView used for?
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 18 Sep 2007 05:16:35 -0400
- Thread-topic: What's the argument aTableView used for?
on 2007-09-18 4:54 AM, Frank Bettger at email@hidden wrote:
> wouldn't it be cleaner if you had multiple dataSource
> objects, one for each NSTableView instance. (Even if there are
> interdependencies between the tables there is nothing preventing you from
> reading other table models from within your code.) Is there any advantage to
> use the same object for multiple NSTableView instances?
Here's my take on it:
A data source object is defined as an object that implements the required
data source methods.
There is typically no reason to clog up your code with multiple classes, all
of which implement the same data source methods but with different code for
each of them. It's easier to have a single data source object whose methods
branch internally according to which table view is passed in. Often, in
fact, the data source methods are simply placed in your window controller,
so that the window controller is the data source object, in addition to
playing all its other roles. This is especially sensible if all your data
comes from some external repository.
On the other hand, the runtime will parse out separate data source classes
with roughly the same branching, so either technique will be of roughly
equal efficiency. A fairly common model, done as you suggest, is to
encapsulate a particular set of data, such as an array, and its data source
methods in the same class, and in that case there is good object-oriented
justification for creating a separate class for each group of data and data
source methods. But there is no requirement that the data and the data
source methods be in the same class.
In the end, it's just a matter of which technique you find more
understandable for a particular application.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
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