A Beginner’s Guide to Object-Oriented Programming with Apex: 3. Polymorphism

This is part 3 in the series “A Beginner’s Guide to Object-Oriented Programming with Apex” and will cover the aspect of Polymorphism. For other posts in this series see the links below. A Beginner’s Guide to Object-Oriented Programming with Apex What the hell is Polymorphism? Polymorphism has the funkiest name and is my favourite aspect of OOP. If done correctly you will feel like a proper genius. Originating from Greek words, polymorphism more or less means “many forms”. This gives away very little unless you know polymorphism quite well but essentially polymorphism describes the ability of a type e.g. a set of differing Apex classes, to be used in similar ways without knowing much about those classes. An immediate example on the platform is the Type.format() static method available on Integers, DateTime, etc**. Although each of the Types represents something different this method does a similar thing for each i.e. turns …

Read more