Re: Correct approach?
Re: Correct approach?
- Subject: Re: Correct approach?
- From: Keary Suska <email@hidden>
- Date: Wed, 27 Jun 2007 11:20:30 -0600
- Thread-topic: Correct approach?
on 6/27/07 10:38 AM, email@hidden purportedly said:
> I see. Thanks for the advice. One question I have is about the NSOpenPanel and
> controller. Currently I have the add button linked to the LibraryController
> which then creates a new book.
> Would I, in the correct approach, connect the new Controller class (that calls
> NSOpenPanel) to the add button? If so, I have to then send the new book back
> to the libraryController (where it is stored in the array and which is also
> the tableView's data source), correct?? The new controller class will also
> have to call some file handling routines to get some data out of the files, so
> it would make sense to separate this fucntionality out and have the book class
> as a pure data object.
Having the NSOpenPanel stuff in your LibraryController is not "wrong",
necessarily. It still fits within the role of the class, and may simplify
your code. It's an OOP judgment call--some "experts" will say your class is
too complicated, but then they would probably not like a lot of Cocoa
objects as well.
Whether or not to separate out the file parsing functionality from the book
class is another judgment call. On the one hand, there is the encapsulation
rule, so no other object should know how a book object stores data. Of
course, data access can be defined in the class interface so another object
has fine-grained control. On another hand, if the book class handles its own
parsing, if you choose to add/remove/change data elements, you only have to
change code in one class. Adding a third hand, if the file being parsed is
not directly related to the book class, e.g. a library of congress record,
then it makes more sense generally to separate out the parsing. It all
depends ;-)
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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