CompTIA Tech+ (FC0-U71)Software Development ConceptsMedium
A software architect is designing a system where different modules need to interact with each other without knowing the intricate internal details of how each module performs its tasks. For example, a 'Print' module should simply receive data and print it, without caring about the specific printer model or driver. Which object-oriented principle is being applied here?
- AAbstraction
- BEncapsulation
- CPolymorphism
- DInheritance
Show answer & explanationAnswer & explanation
Correct answer: A. Abstraction
Abstraction focuses on showing only essential information and hiding complex implementation details. In this scenario, the 'Print' module exposes a simple interface (e.g., a 'printData' method) while concealing the underlying complexities of printer drivers and hardware, which is a classic example of abstraction.
Why the other options are wrong
- B. Encapsulation bundles data and methods that operate on the data within a single unit, controlling access, but doesn't primarily deal with hiding complex logic from external modules.
- C. Polymorphism allows objects of different classes to be treated as objects of a common type, enabling a single interface for different underlying forms.
- D. Inheritance allows a new class to acquire properties and methods from an existing class, focusing on code reuse and hierarchical relationships.
Abstraction (OOP)
Abstraction is an object-oriented programming principle that focuses on showing only essential attributes and interactions, while hiding complex underlying implementation details.
- Reduces complexity by providing a simplified view.
- Achieved through abstract classes, interfaces, or simply good design.
- Allows users to interact with objects at a higher, more conceptual level.
Memory trick: OOP principles are the building blocks of flexible software.