Skip to content

Commit 89a0725

Browse files
Merge pull request ryanmcdermott#147 from LiranBri/composition-over-inheritance
fix is-a order in Prefer composition over inheritance description
2 parents 00a5068 + ec8dbd1 commit 89a0725

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
@@ -1582,7 +1582,7 @@ depends on your problem at hand, but this is a decent list of when inheritance
15821582
makes more sense than composition:
15831583

15841584
1. Your inheritance represents an "is-a" relationship and not a "has-a"
1585-
relationship (Animal->Human vs. User->UserDetails).
1585+
relationship (Human->Animal vs. User->UserDetails).
15861586
2. You can reuse code from the base classes (Humans can move like all animals).
15871587
3. You want to make global changes to derived classes by changing a base class.
15881588
(Change the caloric expenditure of all animals when they move).

0 commit comments

Comments
 (0)