I hope to make this post a bit more note-like rather than exploratory and to provide a summary of the course in a fairly concise way. I don't normally read the text so most of the terms were googled... As the course progresses and new concepts mastered, hopefully this post will grow... Some key words are underlined.
A data type consists of both attributes and methods.
Object oriented language allows for a way to create custom data types and also a way to create instances of that custom data type.
Class is the definition of objects.
Encapsulation is a idea that attributes and associated methods are combined into some data type allowing the client to interact with the public interface without worrying about the details of is implementation. In class we learned about property function in Python which allows the Class to control how the client accesses or changes its attributes.
Inheritance is the act of deriving from another so that the inheriting class (child class) is obtaining methods and attributes from its parent class. Note that the child class is a type of the parent class. Rather than thinking about them as inheritance, I think subsets is a better way to describe it, eventhough child classes can be extended.
Polymorphism is the ability of related data types to respond to the same calls in data type specific ways. In class, we learned about using NotImplementedError on the parent class to implement this kind of behaviour. (but NotImplementedError is not the only way to achieve polymorphism. sometimes, parent class may be implemented, but overriden or extended)
Extending is the act of making a child class more specific. This can be done by adding attributes or methods not defined in the parent or by overriding parent behaviour (methods). For example, suppose parent does x. the child can do xy.
Overriding is the act of literally overriding parent behaviour. For example, suppose parent does x when x is called. The child can ignore that and just do y.
I found this post to be a good overview of some of the concepts covered in class. This person recaps how to approach the design of a class in a manner consistent with our lecture. A lot of other OOP posts were a good summary, but nanalelfe's post is interesting in that if you only know OOP, there's nothing to compare to and thus it cannot be truely understood. I would argue though that although Python is a OO language, Python we learn in csc108 is not.
Anyhow, if you feel like I've missed any important terms or made a mistake, feel free to leave a comment!
No comments:
Post a Comment