Re: Cocoa and Computational Expense
Re: Cocoa and Computational Expense
- Subject: Re: Cocoa and Computational Expense
- From: Roland King <email@hidden>
- Date: Sun, 21 Jun 2009 14:17:56 +0800
On Jun 21, 2009, at 1:50 PM, Justin Carlson wrote:
Finally, on a side note and because this is my first OOP, just how
big should a class get? Just as a rule of thumb. I have 700 lines
and 50 methods in my MyDocument class and it seems positively
bloated to me.
It probably is too large, but I really couldn't answer this
considering the amount of information provided. I tend to use
relatively small objects, many of my objc classes are quite small 2
or 3 ivars and around 100 lines of implementation. I also use a fair
amount of C++. My C++ classes are even smaller, though I am more
interested in reuse than a lot of programmers out there.
One thing I've started doing with my classes which were getting a bit
out of hand is using categories to split them up into different source
files and group task-related methods together. For instance in a
recent (and still-unfinished) piece of game code, I made it possible
to define a level in XML and used the XML event-driven parser to parse
it. Each class is responsible for parsing its related XML so I ended
up with a load of such methods sprayed around the class files which
were already getting a little unwieldy. So I moved them all to
categories YourClass ( XMLParse ) and put them in separate files. This
has certainly made my code easier to read, when I'm working on the
'real' code I'm in one set of files, when I'm adding some XML-related
stuff, I'm elsewhere. Currently I have separate files for each class
which parses XML but actually I could probably have put them all in
one or two.
_______________________________________________
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