Design Patterns · Middle · Question 20 of 75
A UserCard component takes user: User (30 fields) but uses only the name and avatar. Which principle is violated?
- ✓Correct answer: Interface Segregation: the component depends on data it doesn't need
- 2Open/Closed: the component can't be extended without modification
- 3Single Responsibility: the component displays user data
Explanation
With a narrow interface { name, avatarUrl }, the component can be used for a comment author or a chat participant, and tests don't need a full object. Also, changes to the User type won't affect the component.