Class Clusters in Objective-C.

Report
Question
16 views

Please explain why do you think this question should be reported?

Report Cancel

Class clusters are a design pattern that the Foundation framework makes extensive use of. Class clusters group a number of private concrete subclasses under a public abstract superclass. The grouping of classes in this way simplifies the publicly visible architecture of an object-oriented framework without reducing its functional richness. Class clusters are based on the Abstract Factory design pattern.

To make it simple, instead of creating multiple classes for similar functions, we create a single class that will take care of its handling based on the value of input.

For example, in NSNumber we have many clusters of classes like char, int, bool and so on. We group all of them to a single class that takes care of handling the similar operations in a single class. NSNumber actually wraps the value of these primitive types into objects.

Please follow and like us:

About the Author