Re: Decomposing an interface into separate nibs
Re: Decomposing an interface into separate nibs
- Subject: Re: Decomposing an interface into separate nibs
- From: "Kyle Sluder" <email@hidden>
- Date: Wed, 19 Nov 2008 21:22:37 -0500
On Wed, Nov 19, 2008 at 1:05 PM, Frank Wilson <email@hidden> wrote:
> What I want to do is be able to decompose a particular interface into
> several nibs. Sometimes this feels right to me because I feel that one
> component on the interface can be reused separately. In fact, it might
> represent one unit of functionality that I might like to test separately.
Interface decomposition is useful even outside of these scenarios. It
tends to lead to more manageable interactions, often by forcing you to
factor your controller code out a bit more. There is, of course, a
point of absurdity, but the general wisdom is "one window, one nib",
or "one view, one nib" when you're doing things like swapping portions
of a window in and out based on toolbar selections.
> I'll use the Master-Detail example from [1] as a running example.
> What I would like to do is workout how to put the "Detail" part of the
> interface in a separate nib. I think this would be good because
> it would give the flexibility to move this part of the interface to a sheet
> if required.
On the flip side, there's the principle of YAGNI (You Ain't Gonna Need
It). Why would you want to present the detail interface in a sheet?
The Master-Detail interface works because one can quickly switch
between items in the Master view and see the Details change.
> I've thought about subclassing NSView and loading the nib on
> initialization however I would still need instantiate another NSView
> inside so I could layout the components using the interface builder.
> This seems a bit ugly to me and makes me think im not doing the right thing.
If there's a one-to-one relationship between a view and a window (that
is, if a view is only ever used in one place in your interface) then
it probably doesn't belong in its own nib. If multiple views can be
swapped in and out in a window, or the same view[1] can be found in
multiple windows/sheets, then it's a good candidate for factorization.
And nothing says that you have to put the factored view inside another
view; you can use an empty NSView object to do your layout and then
kill it off before feature-freezing your interface, or you can just
swap the empty view out and replace it with the other view.
[1] Of course, by "same view" I'm talking about "another instance of
the view in the nib", not the same exact NSView object, which wouldn't
make sense.
HTH,
--Kyle Sluder
_______________________________________________
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