I'm working on an iTunes style library app.
In my main window controller, I'll be receiving notifications when items are selected in the source list and updating the main content view by triggering the appropriate view controllers. The items being selected have properties defined as global constants that indicate their type. To use iTunes as an example, when you select music from the source list, the righthand view updates to load the music view, when you select the iTunes store, you get that view, etc.
I've read that using a switch statement to do different things based on what's passed in is a code smell, so I'm wondering what the alternative might be to something like:
In my main window controller, I'll be receiving notifications when items are selected in the source list and updating the main content view by triggering the appropriate view controllers. The items being selected have properties defined as global constants that indicate their type. To use iTunes as an example, when you select music from the source list, the righthand view updates to load the music view, when you select the iTunes store, you get that view, etc.
I've read that using a switch statement to do different things based on what's passed in is a code smell, so I'm wondering what the alternative might be to something like:
Code:
int propertyType = [passedInObject valueForKey: propertyType];
switch( propertyType )
{
case kPropertyType0:
// Activate viewController for property type 0
break;
case kPropertyType1:
// Activate viewController for property type 1
break;
case kPropertyTypeN:
// Activate viewController for property type n... etc.
break;
}