Object-oriented programming (OOP) is a popular programming paradigm used to create modular and reusable software components. One of the key aspects of OOP is the ability to create hierarchies of classes, with each class inheriting properties and methods from its parent class. This approach allows for more efficient and organized programming, and is particularly useful when dealing with complex software systems.
In this article, we will discuss a hierarchical design approach for OOP, using a simple example of a shape calculator program. The program allows users to calculate the area and perimeter of various shapes, including circles, rings, and right triangles.
The first step in our design approach is to create an abstract class that serves as the parent class for all the shapes. This abstract class contains some predefined variables and abstract functions, which have no implementation but are designed to be implemented in the derived classes.
We then create separate classes for each type of shape, with each class inheriting from the abstract class. These derived classes contain the implementation of the abstract methods, with each class implementing the methods in a way that is specific to that particular shape.
To handle user input and selection of shapes, we create a separate class called “handler”, which takes two parameters: “type” and “shape”. The “type” parameter refers to the parent class (“Shape”), while the “shape” parameter refers to the specific derived class.
Using this hierarchical design approach, we can easily add new shapes to the program by simply creating a new derived class that inherits from the abstract parent class. This makes the program more modular and extensible, as new shapes can be added without having to modify the existing code.
We also used Visual Studio Professional 2013 as our integrated development environment, which provided a better and more understandable environment for development. The error interpretation was also far better, with highlighting of errors and suggestions for resolving bugs.
In conclusion, a hierarchical design approach for OOP is a powerful tool that can help programmers create modular and reusable software components. By using this approach, we can easily add new features to our programs without having to modify the existing code, making our programs more efficient, organized, and extensible.






