For question regarding the teaching of the object oriented paradigm. This can also be used in conjunction with more specific tags such as inheritance and classes.

The object oriented paradigm is the pattern of code reuse by using templates. These templates are called classes. From a template (class) an instance of the class can be created, which would be something that is a part of that class. For example, an instance of Dog would be a specific Dog, for example my pet Fido. Fido would be an instance of the Dog class. Here, Fido would be an object with the class Dog. Dog is not an object, it is a class which is a template for creating Dog objects.

In addition, classes have inheritance. This is where the characteristics of one class can be passed on to another, or inherited by it. For example, a Dog class could inherit from an Animal class. Any animal has a species. This means that because Dog inherits from Animal, every Dog will also have a species. A dog may also have a breed. If Dog inherits from Animal, that doesn't mean that every Animal also has a breed. You could also construct a Rat class which inherits from the Animal class. That also would not have a breed, because it doesn't inherit from dog, but it would have a species because it inherits from Animal. The Rat class could have a property called tooth_length.

Every class can have methods and properties. These are pretty much what they sound like. For the Dog class, it could have a few properties like breed, bark, name, owner, age, alive, and color. The Dog could also have methods, for example it could have a greet method where is will print it's name, owner and breed. It could have a birthday method which would increment it's age by 1. It could have a death method that would change alive to false.

Every class must have an initialization method, also called a constructor, which is how an instance is created. The arguments to the initialization method are used to create all the initial properties of an instance. For example, when a dog it initialized, alive could be initialized to true while breed, age, and bark could be set through arguments.

In summary, the object oriented paradigm (OO) is about how different objects can be created as instances of classes, and how each class is made up of properties and methods.

history | excerpt history