What's the point of abstract classes?

TheBigK

Well-known member
You aren't defining anything in the methods anyway! So why create the abstract class in first place and then have the child extend its functionality? I can do almost everything with the child class; without defining the abstract class.
 
It helps ensure consistency in related child classes.

As an example, say for instance you wanted a application to support several databases. So you want a wrapper class for all the DB methods you need. You write a wrapper for MySQL, and ones for MSSql. Using an abstract you can ensure that each different wrapper implementation has the same methods, with the same parameters. While you could do it without, it leaves room one of those wrapper classes to miss a required methods, use different naming schema, miss a parameter, etc.

Also say you release this, and someone else wants to come along and use say... MongoDB. Having that abstract will hopefully give them all they need to fully implement the wrapper for the new database, and know exactly what methods they need to implement to fully support it in the application
 
Top Bottom