Abstract Data Types are a really cool concept. I like the idea of making a generic class with all the properties that a subclass may require and then in the subclass you can always override the implementation and customize it to what's needed. This helps making code modular and adding stuff gets a lot easier.
I can imagine this being good for applications that have many objects that are all similar but slightly different. I think of a game for example. All enemies in the game have some common properties such as an x and y coordinates and maybe health but they would all have a different special ability so that feature would be implemented in the child class while the other properties like coordinates and health only need to be implemented once in the parent class. If you want to enforce that all enemies have a special ability you can always add the special ability function to the super class but throw a NotImplemented error and that way there can be no objects of the super class but you would have to make a child class and override the special ability method otherwise when that method is called it will give an error.
This helps with making code modular because now if I want to add a new enemy I do not need to edit the super class, I can simply extend it and make whatever I want.
Overall I think ADT are one of the most useful concepts when combined with other OOP concepts like inheritance and using ADT can really make a difference in how well designed the structure of a program is.
No comments:
Post a Comment