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?

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.

Further reading

Problem with a question

Design Patterns · Middle · question 20

Test yourself

Take the Design Patterns · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz