Abstract Data Types and Object-Oriented Design: Building Modular and Reusable Structures for Effective Programming
Abstract Data Types (ADTs) help a software engineer describe data structures by defining its behavior through a set of operations while hiding the implementation details. By using abstraction and encapsulation, objects become modular and reusable. ADT creates a blueprint for how any object of that object type should be defined and what operations can be used to perform a specific collection of tasks. This means a software engineer would know upfront that creating a Candy object regardless of its type: Snickers, lollypop, or M&Ms will include shared definitions and behaviors. ADT allows software engineers to transform the way they think about programming to include modular program architecture that is readable and reusable when considering data structures, as opposed to focusing only on the implementation details of the data structure. It suggests that software engineers should consider how data structures associate with each other and what a program should do before ever drafting the first line of code.
Similarly, inheritance helps a software engineer describe relationships between classes. By using the principles of inheritance, parent classes serve as a blueprint for more detailed child classes. A parent class would hold all of the behaviors like eating, walking, and sleeping for an “Animal” class. The child classes “Cat” and “Dog” would inherit all of the behaviors from the “Animal” class. Cats and Dogs would eat, walk, and sleep because they inherit from the “Animal” class. It allows classes to be modular and reusable. Instead of defining the same features of an animal multiple times, a parent class serves to define a baseline for the behaviors of all of its child classes. In this way, we consider the relationships of classes. This allows “Cat” and “Dog” classes to add behaviors like meow and bark into their own child classes while keeping the shared parent behaviors in the parent class.
Reference:
Coding Ninjas. (n.d.). Abstract data types in C++. https://www.codingninjas.com/studio/library/abstract-data-types-in-cpp#:~:text=In%20C%2B%2B%2C%20an%20Abstract,high%2Dlevel%2C%20abstract%20way.
W3schools. (n.d.). C++ inheritance. https://www.w3schools.com/cpp/cpp_inheritance.asp
Comments
Post a Comment