• 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: Dictionaries or custom class containing no methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dictionaries or custom class containing no methods?


  • Subject: Re: Dictionaries or custom class containing no methods?
  • From: Trygve Inda <email@hidden>
  • Date: Tue, 17 Jun 2014 16:39:40 -0700
  • Thread-topic: Dictionaries or custom class containing no methods?

>
> On Jun 17, 2014, at 4:16 PM, Trygve Inda wrote:
>
>>> Doesn't seem weird to me, I do it all the time. One advantage of using a
>>> custom class over a dictionary is that the compiler knows what's expected of
>>> it, while a dictionary is just a black box.
>>>
>>>
>>> On Jun 17, 2014, at 3:21 PM, Trygve Inda wrote:
>>>
>>>> I need to store a large collection of settings (not application
>>>> preferences,
>>>> but parameters describing how complex data is to be displayed) and am
>>>> looking for pros/cons as to the best way.
>>>>
>>>> At the top I have a class called MySettings. Within this I need to have
>>>> groups of related settings. They can either be NSMutableDictionary or a
>>>> custom class containing properties, but no methods.
>>>>
>>>> @interface MySettings : NSObject
>>>> {
>>>>   MySettingsAppearance*    appearance;  // size, graphic style etc.
>>>>   MySettingsColors*        colors;      // colors for different elements
>>>>   MySettingsLocations*     locations;   // array of data
>>>>
>>>>   ... About 8 more like these ...
>>>> }
>>
>> Would you use a class-naming scheme like I have outlined?
>
>
> It looks overly generic to me, but I assume you simplified it for the list,
> especially since you said your main class was already MySettings :)
>
> When it's associated with another class like that, I'd do something like use
> the owning class (MySettings) as a prefix - so maybe MySettingsConfiguration.
> But then a lot of time I'm using this for C++ structs, so foo::Bar::Struct
> becomes MyFooBarStruct (namespaces! So awesome! But I guess we aren't ever
> getting them for Cocoa now :( )

Yup... I am using MySettings as a prefix, but of course the real class name
is different... Just that I am using the main class name as a prefix for all
the other (8 or so) classes that form a part of it.

Seems much better to group related ones like this than to try shoving
everything into the main MySetting class.

Trygve



_______________________________________________

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


References: 
 >Re: Dictionaries or custom class containing no methods? (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Dictionaries or custom class containing no methods?
  • Next by Date: Re: Color closest to color
  • Previous by thread: Re: Dictionaries or custom class containing no methods?
  • Next by thread: Re: Dictionaries or custom class containing no methods?
  • Index(es):
    • Date
    • Thread