O'Reilly logo

Mastering iOS 10 Programming by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Checking for traits instead of types

In classic OOP, you often create superclasses and subclasses to group together objects with similar capabilities. If you thoroughly modeled a part of felines in the animal kingdom with classes, you'd end up with a diagram that looks like this:

Checking for traits instead of types

If you've ever tried to model more animals, you would know that it's a really complex task because some animals share a whole bunch of traits although they are actually quite far apart from each other in the class diagram.

One example would be that both cats and dogs are typically kept as pets. This means that they should optionally have an owner and maybe a home. But cats ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required