• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Class design question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class design question


  • Subject: Re: Class design question
  • From: Andy Armstrong <email@hidden>
  • Date: Sun, 13 Feb 2005 18:01:31 +0000

On 13 Feb 2005, at 17:33, Ken Tozier wrote:
In the second pass I created dedicated classes for each data type which adheres better to the Cocoa way of doing things, but yielded twenty different classes that vary only in the size of a single instance variable (Much like NSNumber) These classes are very nice in the sense that they're easy to use and code but it seems incredibly wasteful to have 20 different fairly large classes to handle a difference of a single variable.

If these subclasses literally differ only in the size of the data they encapsulate then surely you just need a pointer to a variable sized chunk of memory? But surely they must differ in more than that? Otherwise what were all the function pointers for in your first design?


It seems like this problem is tailor made for C++ templates, write one class and template the changing variable but I've always hated the way you have to call C++ template classes. Also my C++ experience is very limited so don't know if it's awkward to mix it with Objective C.

Can you tell us more about the problem? What are the twenty different types of thing (or at least what are some of them - to give us a flavour).


--
Andy Armstrong, hexten.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Class design question
      • From: Ken Tozier <email@hidden>
References: 
 >Class design question (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Class design question
  • Next by Date: Re: Class design question
  • Previous by thread: Re: Class design question
  • Next by thread: Re: Class design question
  • Index(es):
    • Date
    • Thread