Object Oriented programming paradigm uses inheritance to model relationships between entities that follow Generalization-Specialization relationship. Here, a Base class is used to encapsulate the common (General) attributes and behavior of a set of entities and the Derived Classes extend the base class by adding additional attributes and/or adding/modifying existing behavior.
As someone new to Functional Programming, I need guidance on modeling such relationships in functional languages like F#.
e.g. what would be the best approach to model a simple situation like the following:
abstract class Tutorial {
private String topic;
abstract public void learn();
}
class VideoTutorial extends Tutorial {
private float duration;
public void learn () {
System.out.println ("Watch Video");
}
}
class PDFTutorial extends Tutorial {
private int pageCount;
public void learn () {
System.out.println ("Read PDF");
}
}
and then later use a collection of Tutorials and call learn to observe polymorphic behavior.