Creating Abstract Classes

introduction to an abstract class and its implementation using a stock trading example

Abstract classes are classes that cannot be instantiated. For instance, if we have the Shape class, we cannot do much with a generic shape until we know what kind of shape we are talking about.

Often, you have a couple of business objects on the same level. Assuming that you are not in the WET (We Enjoy Typing) group of developers, it is natural that you abstract the common functionalities into a base class. For instance, in the case of stock trading, you may have a BarChartView, a LineChartView, and a CandlestickChartView. The common functionalities related to these three views are abstracted into a ChartView. If you want to make ChartView abstract, do the following:

Get hands-on with 1400+ tech skills courses.