volume_mute

Interface Design Principle

publish date2026/06/13 06:39:43.268981 UTC

volume_mute

Why should data representation be hidden from an interface specification, with only operations included?

Correct Answer

Because hiding data representation means it can be easily changed without affecting the objects that use that data - for example, changing a stack's array representation to a list representation without affecting objects that use the stack

Explanation

Hiding data representation in an interface specification leads to a more maintainable design. Since the data representation is hidden, it can be changed without affecting any objects that use that data. For example, a stack's internal representation could be changed from an array to a linked list without changing the interface or any code that uses the stack through its interface. Operations to access and update data should be included; attribute definitions should not.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears