Skip to content

Commit 1429aab

Browse files
committed
Updated readme
1 parent 331de4d commit 1429aab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The Type Objects should share the same interface (or parent) to make it easier f
162162

163163
**When is it useful?**
164164

165-
* When you can't (or don't want to) use class inehritance. Let's say you make a game with animals. You have a base class which is parent to all animals, and then as children to that class you add birds, fish, and mammals. In the bird class you define a flying behavior, which is all fine until you add an ostrich, which can't fly. In that case you have to inherit from the bird class and create new children that can fly and can't fly. But what about bats, which is a mammal that can fly? Another way is to define a flying and a non-flying type in a separate class, so both ostriches remain on the ground and bats can fly.
165+
* When you can't (or don't want to) use class inehritance. Let's say you make a game with animals. You have a base class which is parent to all animals, and then as children to that class you add birds, fish, and mammals. In the bird class you define a flying behavior, which is all fine until you add an ostrich, which can't fly. In that case you have to inherit from the bird class and create new children that can fly and can't fly. But what about bats, which is a mammal that can fly? You don't want to add flying behavior in two separate classes! A better way is to define a flying and a non-flying type in a separate class, so both ostriches remain on the ground and bats can fly.
166166

167167
**Related patterns**
168168

0 commit comments

Comments
 (0)