Question: Imagine we have a system that has a class called Shape and sub classes Square, Circle, and Triangle each developed by a different software engineer.
Imagine we have a system that has a class called Shape and sub classes Square, Circle, and Triangle each developed by a different software engineer. The system uses these classes to create randomly generated visualizations that balance various constraints concerning the area and perimeter of each individual shape along with the total area and total perimeter of all shapes on the screen. (An example of such a constraint might be that the total area of all shapes must always be twice as large as the total perimeters.) One engineer, feeling capricious, decides to implement the getArea() method of the Square subclass by having it return the perimeter of the Square instead. What design heuristic or constraint presented in lectures about classes has this engineer violated and what repercussions will it have in the overall system?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
