O'Reilly logo

PHP 5 Power Programming by Derick Rethans, Stig Sæther Bakken, Andi Gutmans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.12. Abstract Methods and Classes

When designing class hierarchies, you might want to partially leave certain methods for inheriting classes to implement. For example, say you have the class hierarchy shown in Figure 3.2.

Figure 3.2. Class hierarchy.

It might make sense to implement setCenter($x, $y) in class Shape and leave the implementation of the draw() methods to the concrete classes Square and Circle. You would have to declare the draw() method as an abstract method so that PHP knows you are intentionally not implementing it in class Shape. The class Shape would then be called an abstract class, meaning that it's not a class with complete ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required