Object-Oriented Programming is a programming model that stores different concepts into some data structures called objects and those objects are created within classes containing similar features. Then we can interact and manipulate the different attributes of those objects within the classes, and use the methods of the those objects in the same class.
Inheritance is one big concept in Object-Oriented Programming. It's about how we can implement new classes based on already existing classes and then expand the features in our new classes without having to write everything over. When writing classes with inheritance, it's important that we sort out the order and the organization of the classes first. For instance, there is always one parent class called the super class that contains all the starting features, but may also have some methods that can only be determined in the new classes based on this super class, then in this situation, we may raise a NotImplementedError when such methods are classes. After we've got a parent class, by applying the concept of inheritance, we may write subclasses based on the existing parent class without write everything all over again. Another important factor we should be careful about is that we need to be extra careful when we decide to change something in our parent class. Sometimes, some programmers would share the classes they have written to the internet, and people may write code or even implement new subclasses based on those programmers' classes, but if the programmers change some things in the codes they distribute to the internet, the changes may cause all kinds of error and confusion for other people, as the codes in the classes now are different from the past, so remember, it's all connected!
No comments:
Post a Comment