DEV Community

Discussion on: Coding Best Practices Part 1 (Naming Conventions & Class Designing Principles)

Collapse
 
mohitrajput987 profile image
Mohit Rajput

Yes. If IShape has the only getArea() method, it can be used in any shape i.e. Rectangle, Circle, Triangle to the area of that shape. The circle doesn't have width or height so Circle class itself can have a method called getRadius(). Similarly Rectangle can have getWidth() and getHeight().