newbie c to objc... best practices

Post: #1
I have a crap load of static arrays around 90 from small ones like the following:

int littleboy[12][4] =
int bigboy[4][100][4]

in c I would include them in the .h to use them in my methods. I think building objects for these would not only be a pain but a ssslllooowww BIG pain.

what should I do with these?

I also have a few array of strings I thought I could just extern but project builder complains like my ex-wife.

what should I do with these?

I dont see a benefit in creating objects and accessors for all this static data. But what do I know?
Quote this message in a reply
Post: #2
IMO, mistake #1 of those new to OOP is trying to wrap everything under the sun in an object. Seeing a blob and data and going "wow, that's a lot of data, I'd better put it in an object" strikes me as the cart before the horse. OO design should be a little higher level than that. When you think about your problem are there a few concepts that keep coming up that have state and do things?

As a counter argument I do often put big blobs of global data behind a singleton object if only to restrict access to the data and build an abstracting interface to it. But for small projects this can be overkill. (And the same thing can be accomplished in C by putting the data in a file scope variable so that access is restricted to the extern'd file functions.)

Keep things that are essentially functional as functions. Things that are more naturally object should be objects. Don't build deep inheritance hierarchies without having a good use for each of the parents.

So I say, don't sweat it.

On a different note:
When I saw your code snippets I was not thinking "where's the OO?" I was thinking "why isn't that data in a data file?" i.e. big tables of "constant" data compiled in should usually be moved into an external file that's read in at run time. That way you don't have to recompile your code to play with your numbers. Again, if this is a small throw away project, that really doesn't matter either.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ObjC - ZeroLink Problems *Again* Achithyn 7 3,987 Sep 18, 2006 01:25 PM
Last Post: OneSadCookie