Which practice aligns with ADP for module interfaces?

Prepare for the Object-Oriented Programming Test with flashcards and multiple choice questions. Each question comes with hints and explanations to enhance understanding. Master OOP concepts and succeed in your exam!

Multiple Choice

Which practice aligns with ADP for module interfaces?

Explanation:
Depend on abstractions, not on concrete implementations. For module interfaces, the idea is to define a contract (an interface or abstract base) that callers rely on, and have concrete classes implement that contract. This creates loose coupling: callers don’t care which exact class they’re using, so you can swap in a different implementation, evolve the code, and test more easily with mocks or stubs. Relying on concrete classes ties modules together to specific implementations, making changes harder and reducing testability. Exposing implementation details publicly or avoiding interfaces breaks encapsulation and increases fragility, whereas programming to an abstraction keeps boundaries clean and flexible.

Depend on abstractions, not on concrete implementations. For module interfaces, the idea is to define a contract (an interface or abstract base) that callers rely on, and have concrete classes implement that contract. This creates loose coupling: callers don’t care which exact class they’re using, so you can swap in a different implementation, evolve the code, and test more easily with mocks or stubs. Relying on concrete classes ties modules together to specific implementations, making changes harder and reducing testability. Exposing implementation details publicly or avoiding interfaces breaks encapsulation and increases fragility, whereas programming to an abstraction keeps boundaries clean and flexible.